Commit Graph

2 Commits

Author SHA1 Message Date
Maxim 0a2a7737c7 fix(examples): declare agentcore's directly-imported deps
Several packages that agentcore code imports at module scope were never
declared in the pyproject.toml of the project that ships them. They only
resolved because something else happened to pull them in, so the next
`uv lock` that drops the intermediate would silently remove them.

That is newly dangerous: both agent Dockerfiles now install with
`uv sync --locked`, so the installed set is exactly the lockfile rather
than whatever pip incidentally resolved. A dropped transitive would turn
into an ImportError at container start instead of a quiet near-miss.

Undeclared but directly imported:

- boto3 — `agents/utils/ssm.py:12`. `agents/utils/` is COPY'd into BOTH
  agent images, so both agent projects need it; neither declared it.
- PyJWT — `agents/utils/auth.py:11`. strands declared it, langgraph did
  not and resolved it transitively only. langgraph now matches strands
  (`PyJWT[crypto]>=2.10.1`) since it is the same shared module.
- langchain-core — `tools/todos.py:10` imports `langchain_core.messages`
  in the langgraph agent; it rode in on `langchain`.
- botocore — `scripts/utils.py:17` imports `botocore.exceptions`; the
  example-root project declared boto3 but not botocore.

Floors are set at or below what the existing lockfiles already resolve,
so nothing is bumped. The lock diffs are additive metadata only: zero
resolved versions changed and no new packages entered any lock.

Deliberately not declared: `docker/resolve-env.py` (boto3, PyYAML) is
already covered by the root project; `infra-cdk/lambdas/oauth2-provider/`
uses boto3 from the Lambda runtime and is bundled by CDK, not by any of
these three uv projects.

Verification (run, not read):

  $ docker build --platform linux/arm64 \
      -f agents/langgraph-single-agent/Dockerfile -t acuv-lg-a2:test .
  naming to docker.io/library/acuv-lg-a2:test done
  $ docker build --platform linux/arm64 \
      -f agents/strands-single-agent/Dockerfile -t acuv-st-a2:test .
  naming to docker.io/library/acuv-st-a2:test done

  $ docker run --rm --platform linux/arm64 \
      -e GATEWAY_CREDENTIAL_PROVIDER_NAME=dummy -e AWS_DEFAULT_REGION=us-east-1 \
      acuv-lg-a2:test sh -c 'python -c "import langgraph_agent, boto3, jwt, langchain_core, utils.ssm, utils.auth, tools; ..."'
  OK lg 1.43.78 2.13.0 1.6.0
  $ docker run --rm --platform linux/arm64 ... acuv-st-a2:test \
      sh -c 'python -c "import strands_agent, boto3, jwt, utils.ssm, utils.auth, tools; ..."'
  OK st 1.43.78 2.13.0

  $ uv run --locked scripts/test-agent.py --help   # exit 0, usage printed
  $ uv lock --check   # passes for all three projects (14 / 144 / 123 packages)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 17:13:45 +02:00
Maxim 53f34e8cdf chore(examples): lock agentcore agent deps with uv projects
Both AgentCore agents installed from an unlocked `requirements.txt`, so every
image build re-resolved transitive dependencies from scratch. That had already
drifted into a broken state: `langgraph==1.0.10rc1` pulled in a langgraph-prebuilt
that reads `ExecutionInfo` off `langgraph.runtime`, which 1.0.x does not export,
so `import langgraph_agent` failed at container start.

Give each agent a `pyproject.toml` + `uv.lock` and install with `uv sync --locked`,
matching how every other Python integration example is set up. Bump langgraph to
1.1.6 and pin langchain to 1.2.15 — the pair used by
examples/integrations/langgraph-python — to resolve the import failure, and fold
the separately installed `aws-opentelemetry-distro` into the locked dependency
set so it is pinned too.

The example root also gains a `pyproject.toml` + `uv.lock` for the `scripts/`
helpers, whose dependencies were previously declared in a `requirements.txt`
that nothing installed.

Verified by building both images for linux/arm64 and importing the agent module
inside each container.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 16:26:11 +02:00