Skip to content

feat(agent): the project map says which dependencies are missing and where the agent may work - #4537

Merged
kovtcharov-amd merged 10 commits into
amd:mainfrom
kovtcharov:kalin/env-facts
Oct 5, 2026
Merged

kovtcharov-amd merged 10 commits into
amd:mainfrom
kovtcharov:kalin/env-facts

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Agents found out one failed step at a time that the project could not import here and that paths outside the workspace are denied: pip probes, site-packages hunts, cd C:\ and similar. GAIA now states both up front. Each turn says which runtime dependencies the manifest declares are missing from the python on PATH, with nothing from the project imported or run, and the project map names the folders the agent may use. The dependency line rides in the turn, not the system prompt: an install changes it mid-session, and a changed system prompt makes a local model re-read the whole conversation (#4698). The table below was measured with the line in the system prompt.

6 hard SWE-bench tasks, DeepSeek V4.1 Flash without (2 runs) with
"Access denied" hits 8, 7 0
Environment-probing calls 17, 16 11
Repeated failures 6/22, 5/23 1/11
Steps 215, 233 204
Cost $0.52, $0.68 $0.49
Solved 2/6, 3/6 2/6

Test plan

  • python -m pytest tests/unit/agents/test_project_deps.py tests/unit/test_project_map.py hub/agents/gaia/python/tests/test_prompt_prefix_stability.py hub/agents/gaia/python/tests/test_prompt_prefix_stability_project_deps.py: an install and a folder grant between two turns leave the system prompt byte-identical, and the second turn says the dependencies are installed (fails before the fix)
  • In a checkout whose pyproject.toml names an uninstalled package, the user turn carries [Python dependencies NOT installed for python: …]
  • gaia eval agent --category gaia_core

…where the agent may work

Agents repeatedly discovered, one failed step at a time, that the project
could not import here and that paths outside the workspace are denied. The
map now compares the manifest's declared runtime dependencies with what the
python on PATH has installed (nothing from the project is imported or run),
and names the folders the agent may use.
@github-actions github-actions Bot added tests Test changes agents labels Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Verdict: Request changes

The idea is good and the benchmark backs it: telling the agent up front which dependencies are missing and which folders it may use cut "Access denied" hits from about 8 to 0. Two problems need fixing before merge:

  • It crashes every agent on Python 3.10. The new module imports the TOML reader that only exists on Python 3.11+. GAIA still supports 3.10, and every agent loads the project map at import time, so a 3.10 install would fail to start any agent. The repo already has a 3.10-safe import pattern to copy.
  • The "not installed" warning never clears. The project map is cached and only rebuilt when the manifests, folder listing, branch or PATH change. Running pip install changes none of those. So after the agent installs the missing packages, its prompt keeps saying they're missing and that "running its tests fails" for the rest of the process. In a long-running UI server that can last across sessions. That steers the agent back into the probing loop this PR is meant to stop.

One smaller accuracy point: the dependency check skips user-installed packages (pip install --user), so it can report a package as missing when it actually imports fine.

Real-world evidence

N/A — no evidence bundle for this run. The change affects only the agent's system prompt, with no CLI, API or UI output to capture. The PR's SWE-bench table is the behavioural evidence. Apart from that table, this verdict rests on static review.

🔍 Technical details

🔴 tomllib import breaks Python 3.10 (src/gaia/agents/base/project_deps.py:22)
setup.py declares python_requires=">=3.10" and installs tomli on <3.11. project_map now imports project_deps at module level, and project_map is imported by agents/base/agent.py:65. On 3.10, importing the base agent raises ModuleNotFoundError. Use the same guard as src/gaia/schedule/store.py:16:

try:
    import tomllib
except ModuleNotFoundError:  # 3.10
    import tomli as tomllib

🟡 Missing-deps line goes stale after an install (src/gaia/agents/base/project_map.py:392)
missing_python_deps is computed inside _collect, and the result is cached in _MAP_CACHE keyed on _fingerprint, which covers the top-level listing, manifest stat, VCS HEAD and PATH. Installing packages into site-packages changes none of these, so build_project_map keeps returning the old "NOT installed … fails until they are installed" text. Possible fixes:

  • Run the probe outside the cache (it is a single subprocess and only runs when deps are declared).
  • Or add an interpreter-side signal to the fingerprint, such as the site-packages directory mtime.

Please add a test that flips the probe result while keeping the same fingerprint.

🟡 -I hides user-site packages (src/gaia/agents/base/project_deps.py:110)
-I implies -s and -E, so the probe ignores ~/.local/.../site-packages and PYTHONPATH. A project that imports fine from the user's shell then gets reported as having missing deps, which is the false claim the prompt line warns about. -I adds no safety here because only the fixed _PROBE string runs. Dropping it, or using -S-free -E alone if env isolation is wanted, matches what python in the agent's shell actually sees.

🟢 Work-roots line is stronger than the validator (project_map.py:543)
"You can read and write only under: …" holds for non-interactive runs. In a TTY CLI session, PathValidator._prompt_user_for_access asks the user, so outside paths can still be granted. With persisted grants (allowed_paths.json), the list is also unbounded, and it sits in the header, which is outside the token budget. Consider capping the list and wording it as "without asking".

🟢 Unguarded read (project_deps.py:76)
setup_py.read_text and requirements.read_text aren't wrapped for OSError, unlike the pyproject/setup.cfg branches. A permission error would abort the whole map build.

Strengths

  • The project is never imported or executed: the manifest is parsed as data and only importlib.metadata runs in the target interpreter. That's the right safety boundary.
  • Probe failures are logged and return None, and the prompt then says nothing instead of guessing, which fits the fail-loudly rule.
  • Tests cover each manifest format, including marker exclusion, and run a real interpreter probe instead of a mock.

kovtcharov and others added 9 commits October 1, 2026 23:06
…nd on Python 3.10

Addresses review on the project-map dependency check. Agents on Python 3.10 no longer fail to import, since the TOML reader falls back to tomli. The "NOT installed" line now clears once the packages are installed: the probe runs outside the map cache and is re-asked whenever one of the interpreter's search paths changes. The probe now sees user-site packages and PYTHONPATH like the agent's shell does, while running from an empty folder so no project module can shadow its imports. The work-roots line says "without asking" and is capped, and unreadable setup.py/requirements.txt files are logged instead of aborting the map.

Also merges origin/main.
… prompt

The missing-dependency line re-checks after an install, so it changed the
system prompt mid-session, and a granted folder changed the work-roots
line the same way. Either change makes a local model re-read the whole
conversation (amd#4698). The dependency line now rides in the user turn,
next to the indexed-documents line, so it stays current. The work roots
are fixed at the first render; a later grant still applies, only the line
lags it.

A flagship test runs two turns with an install and a grant between them
and checks the prompt does not change while the turn carries the update.
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 5, 2026
Merged via the queue into amd:main with commit 7bbb71a Oct 5, 2026
@kovtcharov-amd
kovtcharov-amd deleted the kalin/env-facts branch October 5, 2026 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants