Open
Conversation
Introduce `agent.deploy()` and `agent.destroy()` methods that package agent code, provision cloud infrastructure (IAM roles, S3 buckets, AgentCore runtimes), and return a live endpoint — all from Python without Terraform, CloudFormation, or Docker. Key components: - AgentCore deployment target with create/update/destroy lifecycle - Automatic code packaging with dependency bundling for Lambda-style runtimes - File-based state management to track deployed resources - Support for custom IAM policies, VPC configuration, and region selection - Protocol-based target abstraction for future deployment backends Includes comprehensive unit tests and documentation with usage examples for rapid prototyping, CI/CD integration, and multi-agent deployments.
…toolkit Replace custom IAM, S3, runtime creation, polling, and endpoint management logic with the bedrock-agentcore-starter-toolkit Runtime class. This removes significant boilerplate from _agentcore.py, _packaging.py, and _constants.py, and adds a new 'deploy' optional dependency group. Tests are updated to mock the toolkit's Runtime class instead of individual boto3 clients.
Relocate the deploy module from strands.deploy to strands.experimental.deploy to signal its experimental status. Remove the agent.deploy() convenience method and top-level deploy export. Update packaging excludes for new artifact paths (.strands_deploy/, .bedrock_agentcore.yaml, dependencies.*), and add a fallback for unsupported Python versions to use the highest supported runtime.
…onfig serialization Replace the template-based agent config extraction approach with AST-based source capture that copies the caller's actual source file, strips the `deploy()` call, and appends an AgentCore wrapper. This preserves tools, plugins, hooks, and all Agent parameters without needing serialization. - Add `_find_caller_info()` to walk the call stack and locate the caller's source file and agent variable name - Add `_DeployStripper` AST transformer to remove deploy-related imports and calls from the packaged source - Update `_build_zip_bundle` to package all CWD files and use the caller's source as the entrypoint - Improve deploy() docstring to document packaging, imports, and dependency behavior - Add comprehensive tests for source stripping, caller detection, and zip bundling
Add design document 0002-deploy.md describing the `strands.experimental.deploy` feature that bridges the gap between local agent development and cloud deployment on AWS Bedrock AgentCore. Covers source capture, entrypoint generation, dependency resolution, state management, and the path to promoting `agent.deploy()` as a stable API.
…ckaging code - Remove `agent_runtime_endpoint_arn` and `role_arn` from DeployResult - Remove `create_code_zip` function and related imports from _packaging.py - Remove `auth` config option from DeployConfig in tests - Update agent name prefix from `strands-` to `strands_` in tests - Clean up deploy output to no longer print endpoint ARN
Remove PACKAGING_EXCLUDES constant, _should_exclude function, and associated tests as they are no longer needed for agent deployment packaging. Update module docstring to reflect reduced scope.
…nstants Replace all print() calls with structured logger.info() using key=value format for better observability. Extract hardcoded strings (entrypoint filename, base requirements, deployment type, build artifacts, runtime name) into named constants in _constants.py to improve maintainability and reduce duplication.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Deploying a Strands agent to the cloud today requires writing a service wrapper, packaging code and dependencies, provisioning infrastructure, and tracking deployed resources — none of which has anything to do with the agent itself. This PR adds an experimental
deploy()function that takes a StrandsAgentand deploys it to AWS Bedrock AgentCore in a single call.The module captures the caller's source file, strips the
deploy()call via AST transformation, appends aBedrockAgentCoreAppentrypoint wrapper, and delegates provisioning to thebedrock-agentcore-starter-toolkit. Deployment state is persisted to.strands_deploy/state.jsonso subsequent calls update rather than duplicate resources. ADeployTargetABC provides a strategy interface for future targets (Lambda, ECS, etc.) beyond the initial AgentCore implementation.The feature is exposed under
strands.experimentalwith an optional dependency (pip install 'strands-agents[deploy]') to allow the API to evolve before graduating toagent.deploy()on the Agent class.Related Issues
Documentation PR
Type of Change
New feature
Testing
Added unit tests across five test files in
tests/strands/experimental/deploy/:test_agentcore.py— AgentCoreTarget validation, deploy (create and update), region resolution, destroy lifecycle, and user agent injection (idempotency, silent failure)test_constants.py— Python runtime mapping and AgentCore name prefixingtest_deploy_integration.py— Top-leveldeploy()function: config construction, name sanitization, environment variable passthrough, unknown target rejection, and import verificationtest_packaging.py— AST-based deploy call stripping,__main__block removal, non-deploy code preservation, and error on missing caller sourcetest_state.py— StateManager save/load roundtrip, atomic writes,created_atpreservation on update, multi-deployment coexistence, delete, version stamping, and corrupted file handlingI ran
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.