Add Project class for agentcore.json configuration management#251
Closed
Add Project class for agentcore.json configuration management#251
Conversation
Add new methods to MemoryClient for feature parity with starter-toolkit: - list_actors(): List all actors who have events in a memory - list_sessions(): List all sessions for an actor - add_strategy_and_wait(): Generic method to add any strategy type and wait - enable_observability(): Stub for CloudWatch observability setup (TODO) - disable_observability(): Stub for CloudWatch observability removal (TODO) Also updates _ALLOWED_GMDP_METHODS to include list_actors and list_sessions. Observability methods raise NotImplementedError with reference to starter-toolkit implementation for future implementation.
Add new high-level classes for managing Bedrock AgentCore resources with YAML-based configuration persistence: - Project: Resource registry for managing multiple Agents and Memories with bulk operations (create_all, launch_all, destroy_all) - Agent: Runtime management with support for both pre-built images and source-based builds via CodeBuild (ARM64) - Memory: Memory resource management with strategy configuration Key features: - YAML serialization/deserialization for all configuration - Auto-generation of ECR repositories and IAM execution roles - CodeBuild integration for building ARM64 container images - Comprehensive unit tests for all new functionality
Remove Project resource registry class to simplify the SDK. Agent and Memory classes can be used independently.
…on() - Rename Memory.create() to Memory.launch() for consistency with Agent - Rename Memory.session() to Memory.get_session() with improved docstring - Update error messages to reference launch() instead of create() - Add detailed docstring for get_session() showing MemorySession methods
Since launch(wait=True) is the default and waits for the resource to be ready, the status() method is redundant. - Remove Agent.status() method - Remove Memory.status() method - Remove corresponding test classes
Operations always wait for completion since that's the expected behavior. Removed the wait parameter from: Agent: - build() - deploy() - launch() - destroy() Memory: - launch() - delete() - add_strategy()
Add Build abstract class and concrete implementations for different
deployment strategies:
- CodeBuildStrategy: Builds ARM64 container images using AWS CodeBuild
(default for cloud deployments)
- LocalBuildStrategy: Builds containers locally using Docker/Finch/Podman
- DirectCodeDeployStrategy: Packages Python code as zip for direct deploy
The Agent class now accepts an optional `build` parameter:
from bedrock_agentcore.runtime import Agent, CodeBuildStrategy
# Using CodeBuild (default if source_path provided)
agent = Agent(
name="my-agent",
source_path="./agent-src",
entrypoint="main.py:app",
)
# Using local Docker
agent = Agent(
name="my-agent",
source_path="./agent-src",
entrypoint="main.py:app",
build=LocalBuildStrategy(),
)
New exports from bedrock_agentcore.runtime:
- Build, CodeBuildStrategy, LocalBuildStrategy, DirectCodeDeployStrategy
- Factory functions: codebuild(), local(), direct_code_deploy()
- Agent now only accepts a `build` parameter (no image_uri, source_path, entrypoint) - Added PrebuiltImage class for pre-existing ECR images - Updated CodeBuild, LocalBuild, DirectCodeDeploy to take source_path/entrypoint in __init__ - Added BuildStrategyType enum and updated BuildConfigModel for YAML serialization - Agent.from_yaml() now loads appropriate Build strategy from config - Added prebuilt() factory function - Updated all tests for new API - Backwards compatibility aliases maintained (CodeBuildStrategy, etc.)
- Consolidate PrebuiltImage, CodeBuild, LocalBuild into single ECR class - ECR(image_uri=...) for pre-built images - ECR(source_path=..., entrypoint=...) for CodeBuild - Keep DirectCodeDeploy for S3 zip deployment - Remove build() from Agent, rename deploy() to build_and_launch() - Customer interface: Agent.build_and_launch() → Agent.invoke() → Agent.destroy() - Update tests for new simplified API
- Rename deploy() to launch() in Build abstract class, ECR, and DirectCodeDeploy - Make Agent.launch() idempotent: creates runtime if not exists, updates if exists - Make Memory.launch() idempotent: creates memory if not exists, returns existing if exists - Agent.build_and_launch() now calls build.launch() then agent.launch() - Update tests for new API
- ECR.launch() checks if image_uri is already set before building - DirectCodeDeploy.launch() checks if package_uri is already set before uploading - Returns status "ALREADY_BUILT" or "ALREADY_UPLOADED" for subsequent calls
- Remove build() from Build abstract class - Remove build() from ECR and DirectCodeDeploy implementations - launch() is the only required method - always rebuilds to pick up source changes - Prebuilt ECR just returns image_uri (no rebuild needed)
Simplify Build class hierarchy by removing the strategy_name property. Type differentiation should use isinstance() checks instead. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create Project class to load/save agentcore.json format (starter-toolkit) - Create ProjectConfig Pydantic models matching agentcore.json schema - Move YAML loading/saving logic from Agent/Memory to Project - Remove from_yaml() and save() methods from Agent and Memory classes - Add tests for Project class - Export Project from bedrock_agentcore package Project provides: - from_json() to load agentcore.json and create Agent/Memory objects - save() to generate agentcore.json from Agent/Memory objects - save_deployed_state() for deployed-state.json output - save_aws_targets() for aws-targets.json output - Bulk operations: launch_all(), destroy_all(), status() Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Summary
Projectclass to load/save agentcore.json format (starter-toolkit CLI compatibility)strategy_name, keep onlylaunch()andimage_uri)Usage
Load from agentcore.json and deploy
Create from scratch
New Files
src/bedrock_agentcore/project.pysrc/bedrock_agentcore/project_config.pytests/bedrock_agentcore/test_project.pyAPI Changes
Project class
Project.from_json(path)project.save(path)project.save_deployed_state(path)project.save_aws_targets(path)project.launch_all()project.destroy_all()project.status()project.add_agent(agent)project.add_memory(memory)project.get_agent(name)project.get_memory(name)Breaking Changes
Agent.from_yaml()andAgent.save()- useProject.from_json()insteadMemory.from_yaml()andMemory.save()- useProject.from_json()insteadBuild.strategy_nameproperty - useisinstance()for type checkingTest plan
🤖 Generated with Claude Code