Help us shape the future of Go! Take the 2026 Go Developer Survey

bedrockagentcore

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 39 Imported by: 0

README

Bedrockagentcore

Parity grade: B · SDK aws-sdk-go-v2/service/bedrockagentcore@v1.50.3 · last audited 2026-10-22 (71065ec09)

Coverage

Metric Value
PARITY entries audited 30 (30 ok)
Feature families 6 (6 ok)
Known gaps 11
Structural gaps (can't be emulated) 2
Deferred items 0
Resource leaks clean
Known gaps
  • Unserved operations: AB tests, batch evaluation, payments, recommendations, InvokeHarness, IngestData, InvokeAgentRuntimeCommand, memory extraction jobs, SaveBrowserSessionProfile, InvokeBrowser, UpdateBrowserStream and CompleteResourceTokenAuth have no routes
  • Memory extraction: events are never turned into memory records because strategies need a model; ExtractionMode and ExtractionConfig are accepted and ignored
  • Retrieval: RetrieveMemoryRecords ranks with lexical BM25 only, so records sharing no term with the query are not returned
  • Runtimes: codeConfiguration (S3 code) runtimes cannot be invoked; only container images run, and the emulated ECR registry is reached through the registry-host setting
  • Runtimes: authorizer configuration is not enforced and the invocation payload is capped at 16 MiB by the shared body reader
  • Code interpreter: executeCode runs a fresh python process per call, so variables do not persist between calls; javascript, typescript and the async task tools are rejected
  • Code interpreter: network mode, certificates and filesystem configurations are stored but not applied to the sandbox
  • Browser: no automation or live-view streams, no profiles, and no browser process behind a session
  • Identity: USER_FEDERATION OAuth2 flows are rejected, vendor providers without a discovery document have no reachable token endpoint, and user JWT signatures are not verified
  • Persistence: sessions come back TERMINATED after a restart; warm runtime containers and sandbox files are not persisted
  • Success status codes and error statuses for RuntimeClientError (424), RetryableConflictException (409) and ThrottlingException (429) come from AWS documentation, not SDK evidence
Structural gaps

These do not block an A grade — no implementation could produce real data here because the underlying data source cannot exist in an emulator.

  • Semantic memory search: real retrieval embeds text with a model; the emulator has none, so ranking is lexical
  • Browser automation: a headless browser container with a CDP bridge is out of scope

More

Documentation

Overview

Package bedrockagentcore emulates the Amazon Bedrock AgentCore data plane: agent runtime invocation, memory events and records, code interpreter and browser sessions, and workload identity tokens.

Index

Constants

View Source
const (
	// EngineAuto runs containers when a container runtime is reachable.
	EngineAuto = "auto"
	// EngineNone never starts containers; invocations that need one fail.
	EngineNone = "none"
)

Variables

View Source
var (
	ErrNotFound = errors.New("resource not found")
	ErrNotReady = errors.New("resource is not ready")
)

Errors a Control reports for runtime lookups.

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	Expires  time.Time `json:"expires"`
	Token    string    `json:"token"`
	Account  string    `json:"account"`
	Region   string    `json:"region"`
	Workload string    `json:"workload"`
	UserID   string    `json:"userId,omitempty"`
}

AccessToken is an issued workload access token.

type ConfigProvider

type ConfigProvider interface {
	GetAgentCoreSettings() Settings
	GetAgentCoreEndpointURL() string
}

ConfigProvider extracts AgentCore data-plane configuration from the AppContext Config.

type ContainerRuntime

type ContainerRuntime interface {
	CreateAndStart(ctx context.Context, spec container.Spec) (string, error)
	StopAndRemove(ctx context.Context, containerID string) error
	Exec(ctx context.Context, containerID string, cmd []string) (container.ExecResult, error)
}

ContainerRuntime is the slice of container.Runtime the engine uses.

type Control

type Control interface {
	Runtime(sc Scope, ref, qualifier string) (RuntimeInfo, error)
	Memory(sc Scope, id string) (MemoryInfo, bool)
	Tool(sc Scope, kind ToolKind, id string) (ToolInfo, bool)
	WorkloadIdentity(sc Scope, name string) bool
	Provider(sc Scope, kind ProviderKind, name string) (ProviderInfo, bool)
	SecretValue(arn, jsonKey string) (string, bool)
}

Control resolves the control-plane resources the data plane operates on.

type EngineConfig

type EngineConfig struct {
	Runtime ContainerRuntime
	// Ports hands out host ports for runtime containers; nil picks free OS ports.
	Ports *portalloc.Allocator
	// HTTP reaches agent containers; nil uses an isolated client.
	HTTP HTTPDoer
	// Host is the address published container ports are reached on; default 127.0.0.1.
	Host string
	// EndpointURL is the gopherstack URL as seen from containers (AWS_ENDPOINT_URL).
	EndpointURL string
	// RegistryHost, when set, replaces the host of ECR image URIs so images are pulled from the emulated registry.
	RegistryHost string
	// PythonImage is the code interpreter sandbox image.
	PythonImage string
	// StartTimeout bounds boot until a runtime container answers its health check.
	StartTimeout time.Duration
	PollInterval time.Duration
	StopTimeout  time.Duration
	// IdleTimeout applies to runtimes that set no idleRuntimeSessionTimeout.
	IdleTimeout time.Duration
}

EngineConfig configures container-backed runtimes and sandboxes.

type Event

type Event struct {
	Timestamp   time.Time      `json:"timestamp"`
	Metadata    map[string]any `json:"metadata,omitempty"`
	Branch      map[string]any `json:"branch,omitempty"`
	Account     string         `json:"account"`
	Region      string         `json:"region"`
	MemoryID    string         `json:"memoryId"`
	ActorID     string         `json:"actorId"`
	SessionID   string         `json:"sessionId"`
	EventID     string         `json:"eventId"`
	ClientToken string         `json:"clientToken,omitempty"`
	Payload     []any          `json:"payload"`
	Seq         uint64         `json:"seq"`
}

Event is one memory event of an actor session.

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPDoer is the slice of *http.Client used to reach agent containers.

type Handler

type Handler struct {
	Backend *InMemoryBackend

	DefaultRegion string
	// contains filtered or unexported fields
}

Handler serves the AgentCore data-plane REST API.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler wraps a backend.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations lists the fault-injectable operations.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions lists the regions this handler serves.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase service name for fault rules.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation returns the operation name.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns the memory, runtime or tool the request addresses.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations lists every implemented operation.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the echo handler.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher matches by SigV4 signing name (or the data-plane SDK user agent) plus a known path shape.

func (*Handler) Shutdown

func (h *Handler) Shutdown(_ context.Context)

Shutdown stops every container the service started.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker reaps idle runtime sessions and expired tool sessions.

type InMemoryBackend

type InMemoryBackend struct {
	// contains filtered or unexported fields
}

InMemoryBackend is the AgentCore data-plane state; one coarse lock guards every table.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates an empty backend.

func (*InMemoryBackend) Close

func (b *InMemoryBackend) Close()

Close stops every runtime container and sandbox.

func (*InMemoryBackend) EnableEngine

func (b *InMemoryBackend) EnableEngine(cfg EngineConfig)

EnableEngine switches the backend to container-backed runtimes and sandboxes. Call it before serving.

func (*InMemoryBackend) EngineEnabled

func (b *InMemoryBackend) EngineEnabled() bool

EngineEnabled reports whether containers can be started.

func (*InMemoryBackend) ReapIdle

func (b *InMemoryBackend) ReapIdle()

ReapIdle stops runtime sessions idle past their timeout and terminates expired tool sessions.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all state and stops every running runtime session and sandbox.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads a snapshot; an incompatible version is discarded. Sessions that were READY come back TERMINATED because their sandboxes did not survive the restart.

func (*InMemoryBackend) SetClock

func (b *InMemoryBackend) SetClock(now func() time.Time)

SetClock replaces the time source, which drives idle expiry and token lifetimes.

func (*InMemoryBackend) SetControl

func (b *InMemoryBackend) SetControl(c Control)

SetControl wires the control plane the data plane resolves resources from.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state. Containers and sandboxes are not part of it.

type MemoryInfo

type MemoryInfo struct {
	ID         string
	Strategies []StrategyInfo
	ExpiryDays int
}

MemoryInfo is the control-plane definition of a memory.

type MemoryRecord

type MemoryRecord struct {
	Created    time.Time      `json:"created"`
	Metadata   map[string]any `json:"metadata,omitempty"`
	Account    string         `json:"account"`
	Region     string         `json:"region"`
	MemoryID   string         `json:"memoryId"`
	ID         string         `json:"id"`
	StrategyID string         `json:"strategyId,omitempty"`
	Text       string         `json:"text"`
	Namespaces []string       `json:"namespaces"`
	Seq        uint64         `json:"seq"`
}

MemoryRecord is a long-term memory record.

type Provider

type Provider struct{}

Provider implements service.Provider for the Bedrock AgentCore data plane.

func (*Provider) Init

Init builds the backend and handler, and enables containers when a runtime is reachable.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type ProviderInfo

type ProviderInfo struct {
	Config       map[string]any
	Name         string
	Vendor       string
	SecretARN    string
	SecretJSONID string
}

ProviderInfo is a credential provider with the references needed to resolve its secrets.

type ProviderKind

type ProviderKind string

ProviderKind selects a credential provider family.

const (
	ProviderAPIKey ProviderKind = "apiKey"
	ProviderOAuth2 ProviderKind = "oauth2"
)

Credential provider families.

type RuntimeInfo

type RuntimeInfo struct {
	Env          map[string]string
	ID           string
	ImageURI     string
	Protocol     string
	IdleSeconds  int
	MaxLifetimeS int
}

RuntimeInfo is the deployable view of an agent runtime endpoint.

type Scope

type Scope struct{ Account, Region string }

Scope identifies the account and Region a request operates in.

type Settings

type Settings struct {
	Engine string `` //nolint:lll // config struct tags are intentionally verbose
	/* 218-byte string literal not displayed */
	RegistryHost string `` //nolint:lll // config struct tags are intentionally verbose
	/* 230-byte string literal not displayed */
	PythonImage string `` //nolint:lll // config struct tags are intentionally verbose
	/* 170-byte string literal not displayed */
	IdleTimeout time.Duration `` //nolint:lll // config struct tags are intentionally verbose
	/* 215-byte string literal not displayed */
}

Settings holds the data-plane configuration, embedded in the root CLI command as CLI.AgentCore.

type StrategyInfo

type StrategyInfo struct{ ID, Name, Type string }

StrategyInfo is one memory strategy of a memory.

type ToolInfo

type ToolInfo struct {
	ID   string
	Mode string
}

ToolInfo is a browser or code interpreter definition.

type ToolKind

type ToolKind string

ToolKind selects the sandbox family.

const (
	ToolBrowser         ToolKind = "browser"
	ToolCodeInterpreter ToolKind = "codeInterpreter"
)

Sandbox families.

type ToolSession

type ToolSession struct {
	Created    time.Time `json:"created"`
	Updated    time.Time `json:"updated"`
	LastActive time.Time `json:"lastActive"`
	Config     doc       `json:"config,omitempty"`
	Account    string    `json:"account"`
	Region     string    `json:"region"`
	Kind       ToolKind  `json:"kind"`
	ToolID     string    `json:"toolId"`
	ID         string    `json:"id"`
	Name       string    `json:"name,omitempty"`
	Status     string    `json:"status"`
	Token      string    `json:"clientToken,omitempty"`
	TimeoutSec int       `json:"timeoutSec"`
}

ToolSession is a browser or code interpreter session.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL