Skip to content

Add Project class for agentcore.json configuration management#251

Closed
jariy17 wants to merge 14 commits intomainfrom
feature/agent-memory-project-classes
Closed

Add Project class for agentcore.json configuration management#251
jariy17 wants to merge 14 commits intomainfrom
feature/agent-memory-project-classes

Conversation

@jariy17
Copy link
Contributor

@jariy17 jariy17 commented Feb 3, 2026

Summary

  • Add Project class to load/save agentcore.json format (starter-toolkit CLI compatibility)
  • Create Pydantic config models matching the agentcore.json schema
  • Move YAML loading/saving logic from Agent/Memory to Project class
  • Simplify Build abstract class (remove strategy_name, keep only launch() and image_uri)
  • Make Agent.launch() and Memory.launch() idempotent (create if not exists, update if exists)
  • Build.launch() always rebuilds to pick up source code changes

Usage

Load from agentcore.json and deploy

from bedrock_agentcore import Project

# Load from starter-toolkit agentcore.json
project = Project.from_json("agentcore.json")

# Deploy all resources (memories first, then agents)
project.launch_all()

# Check status
print(project.status())

# Save deployed state (runtimeId, runtimeArn, memoryIds)
project.save_deployed_state("deployed-state.json")

# Access individual resources
agent = project.get_agent("my-agent")
response = agent.invoke({"message": "Hello!"})

# Clean up
project.destroy_all()

Create from scratch

from bedrock_agentcore import Project
from bedrock_agentcore.runtime import Agent
from bedrock_agentcore.memory import Memory
from bedrock_agentcore.runtime.build import DirectCodeDeploy

# Create project
project = Project(name="my-project", region="us-west-2")

# Add agent with direct code deploy
build = DirectCodeDeploy(source_path="./src", entrypoint="main.py:handler")
agent = Agent(name="my-agent", build=build)
project.add_agent(agent)

# Add memory
memory = Memory(
    name="my-memory",
    strategies=[{"type": "SEMANTIC", "namespace": "facts/{sessionId}/"}]
)
project.add_memory(memory)

# Save to agentcore.json format
project.save("agentcore.json")

# Deploy
project.launch_all()

New Files

File Description
src/bedrock_agentcore/project.py Project class for resource management
src/bedrock_agentcore/project_config.py Pydantic models for agentcore.json schema
tests/bedrock_agentcore/test_project.py Project class tests

API Changes

Project class

Method Description
Project.from_json(path) Load from agentcore.json
project.save(path) Save to agentcore.json
project.save_deployed_state(path) Save deployed-state.json
project.save_aws_targets(path) Save aws-targets.json
project.launch_all() Deploy all memories and agents
project.destroy_all() Delete all resources
project.status() Get status of all resources
project.add_agent(agent) Add agent to project
project.add_memory(memory) Add memory to project
project.get_agent(name) Get agent by name
project.get_memory(name) Get memory by name

Breaking Changes

  • Removed Agent.from_yaml() and Agent.save() - use Project.from_json() instead
  • Removed Memory.from_yaml() and Memory.save() - use Project.from_json() instead
  • Removed Build.strategy_name property - use isinstance() for type checking

Test plan

  • All 957 tests pass
  • Project class tests cover: init, from_json, save, resource management, status

🤖 Generated with Claude Code

jariy17 and others added 14 commits February 3, 2026 12:53
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>
@jariy17 jariy17 requested a review from a team February 3, 2026 22:55
@jariy17 jariy17 closed this Feb 3, 2026
@jariy17 jariy17 deleted the feature/agent-memory-project-classes branch February 3, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant