agents-cli icon indicating copy to clipboard operation
agents-cli copied to clipboard

v0.5.0: deploy to agent_runtime builds on the CLI's own Python (sys.version_info), not the project's — fails when a dependency lacks a wheel for that version (e.g. Python 3.14 + litellm)

Open qingvincentyin opened this issue 5 months ago • 3 comments

Summary

agents-cli deploy to --deployment-target agent_runtime (Vertex AI Agent Engine) determines the build/runtime Python version from the interpreter that runs the CLI itself, not from the target project's Python. When agents-cli is installed as a uv tool under a Python that some required dependency doesn't support yet, the server-side build fails with only a generic error. Concretely, with the CLI running on Python 3.14, the build fails because litellm (a transitive dependency of google-adk) has no 3.14-compatible release. This also builds on a Python version that the generated project's own pyproject.toml requires-python = ">=3.11,<3.14" excludes.

Environment

  • agents-cli v0.5.0 (installed as a uv tool; uv 0.11.14)
  • CLI tool environment interpreter: Python 3.14.5 (machine default)
  • Project: scaffolded adk template, --deployment-target agent_runtime, requires-python = ">=3.11,<3.14"

Repro

  1. Have agents-cli installed under Python 3.14 (e.g. uv tool install google-agents-cli on a machine whose default Python is 3.14).
  2. Scaffold an adk agent targeting agent_runtime.
  3. agents-cli deploy --project <PROJECT_ID> --update-env-vars "GOOGLE_CLOUD_LOCATION=global,GOOGLE_GENAI_USE_VERTEXAI=True"

Actual

Error: Deployment failed: {'code': 3, 'message': 'Build failed. The issue might be caused by incorrect code, requirements.txt file or other dependencies. ...'}

The real error is only visible server-side in Cloud Logging (resource.type="aiplatform.googleapis.com/ReasoningEngine"):

ERROR: Ignored the following versions that require a different python version: ... 1.85.4 Requires-Python >=3.10,<3.14 ...
ERROR: Could not find a version that satisfies the requirement litellm==1.85.4
ERROR: No matching distribution found for litellm==1.85.4

Build install paths confirm the builder ran on 3.14 (.venv/lib/python3.14/..., cp314 wheels).

Expected

The deploy should build on a Python compatible with the project (its .venv / requires-python), or fail fast with a clear message instead of a generic server-side build failure.

Root cause

The Agent Engine SDK derives the build version from the calling interpreter when no override is passed — vertexai/_genai/agent_engines.py:

if python_version:
    sys_version = python_version
else:
    sys_version = f"{sys.version_info.major}.{sys.version_info.minor}"

agents-cli does not pass python_version, so the build inherits the CLI's own interpreter (3.14). There is no --python-version flag to override it.

Likely a regression in v0.5.0

The same project deployed successfully on agents-cli v0.3.0, with the CLI on the same Python 3.14 tool environment, even though litellm has never supported 3.14. That implies v0.3.0 derived the build Python from the project (≤3.13), and v0.5.0 changed to the sys.version_info fallback. (Stated as an inference from observed behavior, not a code diff.)

Suggested fixes (in order of preference)

  1. Set the deploy python_version from the Python the requirements were resolved against (the project .venv / uv.lock).
  2. Otherwise honor the project's requires-python upper bound (don't build on an excluded version).
  3. At minimum, add a --python-version flag and warn when the build Python differs from the resolution Python.

Workaround

Run the CLI under a supported Python: uvx --python 3.13 --from google-agents-cli agents-cli deploy ..., or durably uv tool install google-agents-cli --python 3.13.

qingvincentyin avatar Jun 17 '26 21:06 qingvincentyin

We have a significant refactor to our deployment mechanism that will land soon and should cover this, keep your eyes open for 0.6.0.

sushicw avatar Jun 22 '26 17:06 sushicw

Confirmed fixed in v0.6.x — tested live on 0.6.1.

I scaffolded a fresh agent_runtime ADK project and ran agents-cli deploy -d agent_runtime with the CLI tool env on Python 3.14.5 — the exact interpreter that used to make the build stamp 3.14 and fail on litellm (no 3.14 wheel). The deploy succeeded end-to-end in ~3 minutes and created the reasoning engine.

The reason it works now: in 0.6.0 the agent_runtime target switched from reasoning-engine introspection to a container-image build from the project's Dockerfile. The scaffolded Python Dockerfile pins FROM python:3.12-slim and installs with uv sync --frozen against a lock constrained to requires-python = ">=3.11,<3.14". So the build Python is fixed at 3.12 by the Dockerfile, independent of whatever interpreter uv installed the CLI under. A 3.14 CLI now produces a 3.12 image.

One note for the upgrade path: a project scaffolded before 0.6.0 ships no Dockerfile, so agent_runtime deploy stops with a "Dockerfile not found" error. The fix is agents-cli scaffold upgrade to get a Dockerfile, or deploy with the version it was built for (uvx google-agents-cli@<version> deploy).

Good to close. Thanks for the fix.

qingvincentyin avatar Jun 30 '26 16:06 qingvincentyin

This bug is the concrete failure mode behind the Python-version deployment contract.

The remote build should not inherit the CLI tool interpreter version when the project explicitly declares a different compatible Python range.

The deploy environment should be resolved from:

explicit --python-version
  else agents-cli-manifest.yaml
  else project pyproject.toml requires-python
  else template default

not from:

sys.version_info of the Python running agents-cli

A standard AISP V1.0.0 companion contract could describe the required behavior:

[
  {
    "role": "system",
    "content": {
      "protocol": "AISP V1.0.0",
      "axiom_0": "Human_Sovereignty_and_Wellbeing",
      "id": "google_agents_cli_remote_build_python_contract_aisp",
      "name": "Google Agents CLI Remote Build Python Contract",
      "version": "1.0.0",
      "license": "Apache-2.0",
      "summary": "A machine-checkable AISP package for preventing remote Agent Runtime builds from inheriting the CLI interpreter Python version.",
      "flow_format": "mermaid",
      "loading_mode": "node",
      "tools": ["filesystem", "shell"],
      "params": {
        "project_root": "string",
        "cli_python_version": "string"
      },
      "system_prompt": ""
    }
  },
  {
    "role": "user",
    "content": {
      "instruction": "STRICTLY OBEY aisp_contract; its non_negotiable rules are inviolable; then RUN aisop.main",
      "user_input": "{user_input}",
      "aisp_contract": {
        "profile": "aisp.skill.v1",
        "invocation": {
          "mode": "remote_build_validation",
          "when_to_use": [
            "before deploying to Agent Runtime",
            "when CLI Python differs from project Python",
            "when dependency wheels may not exist for CLI Python"
          ],
          "when_not_to_use": [
            "local-only run",
            "project with explicit deploy Python already validated"
          ]
        },
        "non_negotiable": [
          {
            "rule": "Remote build Python must be selected from project/deploy metadata, not CLI sys.version_info.",
            "enforced_by": "select_build_python.step2:sys.assert"
          },
          {
            "rule": "Remote build Python must satisfy project requires-python.",
            "enforced_by": "validate_build_python.step2:sys.assert"
          },
          {
            "rule": "If dependency resolution fails due to Python version, the error should mention selected build Python and project requires-python.",
            "enforced_by": "diagnose.step2:sys.assert"
          }
        ],
        "discovery": {
          "category": "deployment",
          "tags": ["agents-cli", "agent-runtime", "python", "remote-build", "litellm", "aisp"]
        },
        "risk_level": "high",
        "resources": [
          {
            "id": "project_root",
            "path": "{project_root}",
            "kind": "repository",
            "mode": "read_only",
            "when": "Read before remote build Python selection.",
            "scope": "skill"
          }
        ]
      },
      "aisop": {
        "main": "graph TD\n    read_project[Read project metadata] --> select_build_python[Select remote build Python]\n    select_build_python --> validate_build_python[Validate compatibility]\n    validate_build_python --> deploy[Deploy or fail early]\n    deploy --> diagnose[Diagnose failures]\n    diagnose --> end_node((End))"
      },
      "functions": {
        "read_project": {
          "step1": "Read pyproject.toml requires-python, manifest fields, template defaults, and dependency files.",
          "output_mapping": "project_python_metadata"
        },
        "select_build_python": {
          "step1": "Select remote build Python from explicit flag, manifest, project metadata, or template default.",
          "step2": "sys.assert('remote build Python is not CLI sys.version_info unless explicitly chosen', 'Remote build must not inherit CLI Python by default')",
          "output_mapping": "selected_build_python"
        },
        "validate_build_python": {
          "step1": "Validate selected_build_python satisfies project requires-python.",
          "step2": "sys.assert('selected build Python satisfies project requires-python', 'Remote build Python incompatible with project')",
          "output_mapping": "build_python_validation"
        },
        "deploy": {
          "step1": "Proceed with deploy only if build_python_validation passes.",
          "output_mapping": "deploy_status"
        },
        "diagnose": {
          "step1": "If deploy fails, include CLI Python, selected build Python, project requires-python, and dependency resolver error.",
          "step2": "sys.assert('failure diagnostic includes build Python context', 'Deployment failure must show Python version context')",
          "output_mapping": "deploy_diagnostic"
        },
        "end_node": {
          "step1": "Return build_python_validation and deploy_diagnostic."
        }
      }
    }
  }
]

This would prevent the current failure mode:

CLI installed under Python 3.14
  -> remote build uses 3.14
  -> project declares <3.14
  -> dependency wheel unavailable
  -> generic build failure

The deploy command should fail early with a clear Python version mismatch, or select a compatible remote build Python.

optimization2026 avatar Jun 30 '26 17:06 optimization2026