-
Notifications
You must be signed in to change notification settings - Fork 16
fix(agent-challenge): supply LLM_MODEL to the evaluated agent #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
packages/challenges/agent-challenge/tests/test_llm_model_reaches_agent.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| """The LLM model id must reach the agent (VAL-LLM-MODEL). | ||
|
|
||
| The packaged agent fails closed when ``LLM_MODEL`` is unset:: | ||
|
|
||
| agent run failed: A concrete model id is required: set LLM_MODEL | ||
| (the measured review harness supplies it under .rules). | ||
|
|
||
| Three independent layers dropped it, so *every* evaluation scored 0 and every | ||
| ``result.json`` carried ``"model_name": null``: | ||
|
|
||
| 1. the runner never set ``LLM_MODEL`` -- the platform only holds | ||
| ``CHALLENGE_LLM_MODEL`` (settings ``llm_model``), which the agent never reads; | ||
| 2. :func:`sanitize_miner_env_for_job` stripped a miner-supplied ``LLM_MODEL`` | ||
| because the name is not token/key shaped; | ||
| 3. :data:`AGENT_ENV_ALLOWLIST` admitted only ``LLM_COST_LIMIT`` and | ||
| ``OPENROUTER_API_KEY``. | ||
|
|
||
| A miner may bring their own key *and* their own model; when they supply neither, | ||
| the measured platform model is used. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from agent_challenge.core.config import settings | ||
| from agent_challenge.evaluation.own_runner.isolation import ( | ||
| AGENT_ENV_ALLOWLIST, | ||
| filter_agent_env, | ||
| ) | ||
| from agent_challenge.evaluation.runner import _terminal_bench_env | ||
| from agent_challenge.submissions.miner_env import ( | ||
| sanitize_miner_env_for_job, | ||
| validate_miner_env, | ||
| ) | ||
|
|
||
|
|
||
| def test_agent_env_allowlist_admits_llm_model() -> None: | ||
| """Layer 3: the agent sandbox must be allowed to see the model id.""" | ||
| assert "LLM_MODEL" in AGENT_ENV_ALLOWLIST | ||
|
|
||
|
|
||
| def test_filter_agent_env_keeps_llm_model() -> None: | ||
| """Layer 3: the final filter must not strip the model id.""" | ||
| kept = filter_agent_env({"LLM_MODEL": "x-ai/grok-4.5", "OPENROUTER_API_KEY": "sk-or-x"}) | ||
| assert kept["LLM_MODEL"] == "x-ai/grok-4.5" | ||
| assert kept["OPENROUTER_API_KEY"] == "sk-or-x" | ||
|
|
||
|
|
||
| def test_runner_injects_platform_llm_model() -> None: | ||
| """Layer 1: with no miner env, the measured platform model is supplied.""" | ||
| env = _terminal_bench_env() | ||
| assert env["LLM_MODEL"] == settings.llm_model | ||
| assert env["LLM_MODEL"], "platform model id must not be empty" | ||
|
|
||
|
|
||
| def test_miner_may_supply_own_llm_model() -> None: | ||
| """Layer 2: a miner bringing their own key may also choose their model.""" | ||
| assert sanitize_miner_env_for_job({"LLM_MODEL": "openai/gpt-5"}) == { | ||
| "LLM_MODEL": "openai/gpt-5" | ||
| } | ||
| assert validate_miner_env({"LLM_MODEL": "openai/gpt-5"}) == {"LLM_MODEL": "openai/gpt-5"} | ||
|
|
||
|
|
||
| def test_miner_llm_model_overrides_platform_default() -> None: | ||
| """A miner-supplied model wins over the platform default.""" | ||
| env = _terminal_bench_env({"LLM_MODEL": "openai/gpt-5"}) | ||
| assert env["LLM_MODEL"] == "openai/gpt-5" | ||
|
|
||
|
|
||
| def test_llm_model_value_must_not_be_a_url() -> None: | ||
| """Admitting the name must not open an endpoint-injection hole.""" | ||
| assert sanitize_miner_env_for_job({"LLM_MODEL": "http://evil.example/v1"}) == {} | ||
|
|
||
|
|
||
| def test_llm_model_is_not_treated_as_a_secret() -> None: | ||
| """The model id is not secret-shaped, so it must not be flagged as one.""" | ||
| from agent_challenge.evaluation.own_runner.isolation import disallowed_secret_keys | ||
|
|
||
| assert "LLM_MODEL" not in disallowed_secret_keys({"LLM_MODEL": "x-ai/grok-4.5"}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: BaseIntelligence/base
Length of output: 50378
🏁 Script executed:
Repository: BaseIntelligence/base
Length of output: 13298
🏁 Script executed:
Repository: BaseIntelligence/base
Length of output: 33243
Do not add
LLM_MODELto the secret allowlist.MINER_ENV_PRODUCT_ALLOWLISTis the “API key / token / measured product secret” gate;LLM_MODELis an OpenRouter model identifier, not a secret. Keeping it here lets miners submit and persist arbitrary model names throughvalidate_miner_env()/sanitize_miner_env_for_job(); use a separate narrowly scoped model-id validator/allowlist instead.🤖 Prompt for AI Agents
Source: Coding guidelines