Skip to content

fix(bedrock): install boto3 on first use via lazy_deps#26294

Closed
hawknewton wants to merge 1 commit into
NousResearch:mainfrom
AmbulnzLLC:chore/bedrock-lazy-deps
Closed

fix(bedrock): install boto3 on first use via lazy_deps#26294
hawknewton wants to merge 1 commit into
NousResearch:mainfrom
AmbulnzLLC:chore/bedrock-lazy-deps

Conversation

@hawknewton

Copy link
Copy Markdown
Contributor

What does this PR do?

agent/bedrock_adapter.py already defers import boto3 until the provider is actually used, but on a base install (no [all] extras) that deferred import just raises ModuleNotFoundError — there's nothing that actually installs boto3.

tools/lazy_deps.py already registers a provider.bedrock entry pointing at boto3==1.42.89. This PR wires the adapter to call lazy_deps.ensure("provider.bedrock") at module load, so the first import of the Bedrock adapter triggers the install.

The ensure() call is wrapped in try / except Exception: pass so that:

  • Environments where lazy_deps isn't importable (test stubs, etc.) don't break
  • An install failure surfaces as the real downstream ImportError from the existing lazy import block, not a confusing lazy_deps stack

After #24220 / #24515 removed boto3 from the [all] extras, users on a base install hit ModuleNotFoundError: No module named 'boto3' the first time the Bedrock provider is touched, even though the lazy_deps registration was already in place to handle exactly this case.

Related Issue

No open issue — surfaced as a regression after the boto3-from-extras removal in #24220 / #24515.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • agent/bedrock_adapter.py — 13-line try / except block at the top of the module that calls lazy_deps.ensure("provider.bedrock", prompt=False) so boto3 is installed on first import. Pinned version (boto3==1.42.89) comes from the existing tools/lazy_deps.py registration — not changed here.

How to Test

On a clean venv with pip install hermes-agent (no extras):

  1. Confirm the regression on main:
    python -c "from agent.bedrock_adapter import BedrockAdapter"
    # ModuleNotFoundError: No module named 'boto3'
  2. Apply this PR.
  3. Re-run the same import:
    python -c "from agent.bedrock_adapter import BedrockAdapter"
    # lazy_deps installs boto3==1.42.89, import succeeds
  4. Run the existing test suite:
    pytest tests/ -q
    

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (chore(deps):)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix (single 13-line addition to one file)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes — N/A (this is a deps-bootstrap shim that runs at import time; behavior is "lazy_deps installs the package", which is already covered by lazy_deps' own tests)
  • I've tested on my platform: Ubuntu 24.04 (Amazon Linux 2023 runtime)

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A (internal bootstrap shim; user-visible behavior is unchanged)
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guidelazy_deps is the existing cross-platform install path; no new platform-specific code
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

agent/bedrock_adapter.py now calls lazy_deps to install boto3 and
botocore on first import, mirroring how other optional provider
adapters defer their heavy AWS dependencies until actually used.

Keeps the base install slim for users who don't run on Bedrock.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder backend/docker Docker container execution provider/bedrock AWS Bedrock (boto3, IAM) labels May 15, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #24972 which already fixes the same issue (#24967). See also #25088 (another duplicate).

NishantEC

This comment was marked as outdated.

teknium1 added a commit that referenced this pull request May 17, 2026
…tors

Adds release-note attribution mappings for the contributors from group 5:
- @haran2001 (PR #27070, #27068)
- @ms-alan (PR #26443)
- @godlin-gh (PR #26118)
- @wesleysimplicio (PR #25777, ext-email form)
- @Carry00 (PR #26851)
- @alaamohanad169-ship-it (PR #26036)
- @hawknewton (PR #26294)

(YanzhongSu PR #25879 and flamiinngo PR #27231 already mapped.)
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #27382 — your commit was cherry-picked onto current main as part of a batch salvage of low-risk new-contributor PRs. Authorship preserved (chore(deps): lazy-install boto3/botocore for bedrock adapter). Thanks for the contribution.

@teknium1 teknium1 closed this May 17, 2026
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/docker Docker container execution comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists provider/bedrock AWS Bedrock (boto3, IAM) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants