Skip to content

fix: Port agent loader and file path resolution fixes to v1 - #6788

Open
GWeale wants to merge 2 commits into
v1from
backport-v1-pr01
Open

fix: Port agent loader and file path resolution fixes to v1#6788
GWeale wants to merge 2 commits into
v1from
backport-v1-pr01

Conversation

@GWeale

@GWeale GWeale commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Ports two commits from main to v1.

  1. Agent name gating in the CLI server (3f6eb1f0)

    • AgentLoader.load_agent raises PermissionError for a __-prefixed name; set _allow_special_agents on the loader instance to keep loading them.
    • adk api_server answers 403 for those names, including the eval and graph routes. adk web still serves them, via the existing web argument to get_fast_api_app.
  2. Path scoping in the Agent Builder file tools (1fa7cda9)

    • resolve_file_path raises ValueError when the path resolves outside the root directory; the file tools return {"success": False, ...}.
    • It returns a fully resolved path, with .. and symlinks collapsed.

The server-side check is re-implemented for v1's single AdkWebServer rather than ported.

GWeale added 2 commits August 18, 2026 20:31
Port of 3f6eb1f from main.

Any client of a headless `adk api_server` could load and run the special
internal agents that back the dev UI, `__adk_agent_builder_assistant`
among them, by naming one as the app. The agent loader accepted any
`__`-prefixed name unconditionally, and the server never looked at the
prefix.

Loading a `__`-prefixed agent now raises `PermissionError` unless the
loader was configured to allow it, and `AdkWebServer` answers 403 for
those names before it asks the loader at all. `get_fast_api_app` turns
both on from its existing `web` argument, so the dev UI keeps working and
a headless api_server does not.

Behaviour change: driving a special internal agent through
`adk api_server` now returns 403 where it used to run the agent.

Adapted for v1, which has a single `AdkWebServer` rather than the
`ApiServer` and `DevServer` pair upstream writes the flag against.
Upstream guards two `load_agent` call sites; its other four sit on
`DevServer`, which is never constructed when `web=False`, so those routes
do not exist there at all. v1 registers every route on one class, so all
six calls go through a single `_load_agent_or_app` helper that holds the
403. That makes the four eval and graph routes answer 403 where upstream
answers 404, and it is what covers a caller who supplies an agent loader
of their own that ignores the loader flag.
Port of 1fa7cda from main.

`resolve_file_path` returned an absolute path unchanged and joined a
relative one onto an unresolved root without ever checking where the
result landed, so `..` segments and absolute paths both escaped the
project root. The Agent Builder's write, read and delete tools resolve
every path through it, which put arbitrary files on the machine within
reach of whatever the model was told to do.

It now resolves the root and the candidate and raises `ValueError` when
the candidate is not inside the root. Interior `..` that stays inside the
root still resolves, as does an absolute path pointing inside it.

Behaviour change: an Agent Builder session that wrote, read or deleted a
file outside its root directory now gets a tool failure instead. Every
caller of `resolve_file_path` and `resolve_file_paths` already wraps the
call in a `try`, so the new `ValueError` surfaces as
`{"success": False, ...}` rather than a traceback.

The commit's import-isolation test comes along unchanged; it guards a
separate property, that importing `adk_web_server` does not eagerly pull
in the Agent Builder agent stack.
@GWeale GWeale changed the title fix: Port local agent server input validation fixes to v1 fix: Port agent loader and file path resolution fixes to v1 Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants