AWS.BedrockAgentCore reference
BatchCreateMemoryRecords
Section titled “BatchCreateMemoryRecords”Source:
src/AWS/BedrockAgentCore/BatchCreateMemoryRecords.ts
Directly inserts long-term memory records, bypassing asynchronous extraction.
Bind a Memory inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.BatchCreateMemoryRecordsHttp
on the Function effect to implement the binding.
BatchCreateMemoryRecords: Writing Memory Records
Section titled “BatchCreateMemoryRecords: Writing Memory Records”// initconst batchCreateMemoryRecords = yield* AgentCore.BatchCreateMemoryRecords(memory);
return { fetch: Effect.gen(function* () { // runtime const result = yield* batchCreateMemoryRecords({ records: [ { requestIdentifier: "rec-1", namespaces: ["facts/user-1"], content: { text: "The user's favorite color is teal." }, timestamp: new Date(), }, ], }); return HttpServerResponse.json({ created: result.successfulRecords.length, }); }),};BatchDeleteMemoryRecords
Section titled “BatchDeleteMemoryRecords”Source:
src/AWS/BedrockAgentCore/BatchDeleteMemoryRecords.ts
Deletes long-term memory records in bulk.
Bind a Memory inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.BatchDeleteMemoryRecordsHttp
on the Function effect to implement the binding.
BatchDeleteMemoryRecords: Deleting Memory Records
Section titled “BatchDeleteMemoryRecords: Deleting Memory Records”// initconst batchDeleteMemoryRecords = yield* AgentCore.BatchDeleteMemoryRecords(memory);
return { fetch: Effect.gen(function* () { // runtime const result = yield* batchDeleteMemoryRecords({ records: [{ memoryRecordId }], }); return HttpServerResponse.json({ deleted: result.successfulRecords.length, }); }),};BatchUpdateMemoryRecords
Section titled “BatchUpdateMemoryRecords”Source:
src/AWS/BedrockAgentCore/BatchUpdateMemoryRecords.ts
Updates long-term memory records in bulk.
Bind a Memory inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.BatchUpdateMemoryRecordsHttp
on the Function effect to implement the binding.
BatchUpdateMemoryRecords: Writing Memory Records
Section titled “BatchUpdateMemoryRecords: Writing Memory Records”// initconst batchUpdateMemoryRecords = yield* AgentCore.BatchUpdateMemoryRecords(memory);
return { fetch: Effect.gen(function* () { // runtime const result = yield* batchUpdateMemoryRecords({ records: [ { memoryRecordId, timestamp: new Date(), content: { text: "The user's favorite color is green." }, namespaces: ["facts/user-1"], }, ], }); return HttpServerResponse.json({ updated: result.successfulRecords.length, }); }),};BrowserCustom
Section titled “BrowserCustom”Source:
src/AWS/BedrockAgentCore/BrowserCustom.ts
A custom Amazon Bedrock AgentCore Browser — a managed, isolated cloud browser that agents drive to interact with websites.
A custom browser controls the sandbox’s network mode, execution role, and session recording. All configuration is create-only (the API has no update operation); property changes trigger a replacement.
BrowserCustom: Creating Browsers
Section titled “BrowserCustom: Creating Browsers”Public-Egress Browser
import * as AgentCore from "alchemy/AWS/BedrockAgentCore";
const browser = yield* AgentCore.BrowserCustom("AgentBrowser", {});Browser with Session Recording
const browser = yield* AgentCore.BrowserCustom("RecordedBrowser", { executionRoleArn: role.roleArn, recording: { enabled: true, s3Location: { bucket: bucket.bucketName, prefix: "sessions/" }, },});CodeInterpreter
Section titled “CodeInterpreter”Source:
src/AWS/BedrockAgentCore/CodeInterpreter.ts
A custom Amazon Bedrock AgentCore Code Interpreter — an isolated sandbox where agents execute Python/JavaScript/TypeScript code.
A custom interpreter controls the sandbox’s network mode and execution role. All configuration is create-only (the API has no update operation); property changes trigger a replacement.
CodeInterpreter: Creating Code Interpreters
Section titled “CodeInterpreter: Creating Code Interpreters”Sandboxed Interpreter (no network egress)
import * as AgentCore from "alchemy/AWS/BedrockAgentCore";
const interpreter = yield* AgentCore.CodeInterpreter("Sandbox", {});Interpreter with Public Egress
const interpreter = yield* AgentCore.CodeInterpreter("PublicSandbox", { networkConfiguration: { networkMode: "PUBLIC" },});CodeInterpreter: Executing Code from a Function
Section titled “CodeInterpreter: Executing Code from a Function”// initconst startSession = yield* AgentCore.StartCodeInterpreterSession(interpreter);const invoke = yield* AgentCore.InvokeCodeInterpreter(interpreter);const stopSession = yield* AgentCore.StopCodeInterpreterSession(interpreter);
return { fetch: Effect.gen(function* () { // runtime const session = yield* startSession({ sessionTimeout: "5 minutes" }); const result = yield* invoke({ sessionId: session.sessionId, name: "executeCode", arguments: { language: "python", code: "print(1 + 1)" }, }); const output = yield* Stream.runCollect(result.stream); yield* stopSession({ sessionId: session.sessionId }); return HttpServerResponse.json({ output: Array.from(output) }); }),};CreateEvent
Section titled “CreateEvent”Source:
src/AWS/BedrockAgentCore/CreateEvent.ts
Records an interaction event into a memory’s short-term store.
Bind a Memory inside a function runtime to get a callable that
appends conversational turns (or binary blobs) to an actor’s session.
Provide AgentCore.CreateEventHttp on the Function effect to implement
the binding over the AgentCore data-plane API.
CreateEvent: Recording Events
Section titled “CreateEvent: Recording Events”import * as AgentCore from "alchemy/AWS/BedrockAgentCore";
export default MyFunction.make( { main: import.meta.url, functionUrl: true }, Effect.gen(function* () { const memory = yield* AgentCore.Memory("AgentMemory", { eventExpiryDuration: "30 days", });
// init const createEvent = yield* AgentCore.CreateEvent(memory);
return { fetch: Effect.gen(function* () { // runtime const result = yield* createEvent({ actorId: "user-1", sessionId: "session-1", eventTimestamp: new Date(), payload: [ { conversational: { role: "USER", content: { text: "My favorite color is teal." }, }, }, ], }); return HttpServerResponse.json({ eventId: result.event.eventId }); }), }; }).pipe(Effect.provide(AgentCore.CreateEventHttp)),);DeleteEvent
Section titled “DeleteEvent”Source:
src/AWS/BedrockAgentCore/DeleteEvent.ts
Deletes a short-term event from an actor’s session.
Bind a Memory inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.DeleteEventHttp
on the Function effect to implement the binding.
DeleteEvent: Deleting Events
Section titled “DeleteEvent: Deleting Events”// initconst deleteEvent = yield* AgentCore.DeleteEvent(memory);
return { fetch: Effect.gen(function* () { // runtime yield* deleteEvent({ actorId: "user-1", sessionId: "session-1", eventId, }); return HttpServerResponse.json({ deleted: true }); }),};DeleteMemoryRecord
Section titled “DeleteMemoryRecord”Source:
src/AWS/BedrockAgentCore/DeleteMemoryRecord.ts
Deletes a long-term memory record.
Bind a Memory inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.DeleteMemoryRecordHttp
on the Function effect to implement the binding.
DeleteMemoryRecord: Deleting Memory Records
Section titled “DeleteMemoryRecord: Deleting Memory Records”// initconst deleteMemoryRecord = yield* AgentCore.DeleteMemoryRecord(memory);
return { fetch: Effect.gen(function* () { // runtime yield* deleteMemoryRecord({ memoryRecordId }); return HttpServerResponse.json({ deleted: true }); }),};Gateway
Section titled “Gateway”Source:
src/AWS/BedrockAgentCore/Gateway.ts
An Amazon Bedrock AgentCore Gateway — a managed MCP endpoint that turns APIs and Lambda functions into agent-callable tools.
A gateway fronts one or more targets (OpenAPI specs, Smithy models, Lambda functions) behind a single MCP URL with centralized authorization (SigV4 or JWT).
Gateway: Creating Gateways
Section titled “Gateway: Creating Gateways”IAM-Authorized MCP Gateway
import * as AgentCore from "alchemy/AWS/BedrockAgentCore";import * as IAM from "alchemy/AWS/IAM";
const role = yield* IAM.Role("GatewayRole", { assumeRolePolicyDocument: { Version: "2012-10-17", Statement: [ { Effect: "Allow", Principal: { Service: "bedrock-agentcore.amazonaws.com" }, Action: ["sts:AssumeRole"], }, ], },});
const gateway = yield* AgentCore.Gateway("ToolGateway", { roleArn: role.roleArn, authorizerType: "AWS_IAM",});JWT-Authorized Gateway
const gateway = yield* AgentCore.Gateway("JwtGateway", { roleArn: role.roleArn, authorizerType: "CUSTOM_JWT", authorizerConfiguration: { customJWTAuthorizer: { discoveryUrl: `https://cognito-idp.us-west-2.amazonaws.com/${userPool.userPoolId}/.well-known/openid-configuration`, allowedClients: [client.clientId], }, },});GetAgentCard
Section titled “GetAgentCard”Source:
src/AWS/BedrockAgentCore/GetAgentCard.ts
Fetches the A2A agent card describing the agent runtime’s capabilities.
Bind a Runtime inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.GetAgentCardHttp
on the Function effect to implement the binding.
GetAgentCard: Agent Discovery
Section titled “GetAgentCard: Agent Discovery”// initconst getAgentCard = yield* AgentCore.GetAgentCard(runtime);
return { fetch: Effect.gen(function* () { // runtime const result = yield* getAgentCard({}); return HttpServerResponse.json({ card: result.agentCard }); }),};GetBrowserSession
Section titled “GetBrowserSession”Source:
src/AWS/BedrockAgentCore/GetBrowserSession.ts
Reads a browser session’s configuration, status, and stream endpoints.
Bind a BrowserCustom inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.GetBrowserSessionHttp
on the Function effect to implement the binding.
GetBrowserSession: Browser Sessions
Section titled “GetBrowserSession: Browser Sessions”// initconst getBrowserSession = yield* AgentCore.GetBrowserSession(browser);
return { fetch: Effect.gen(function* () { // runtime const result = yield* getBrowserSession({ sessionId }); return HttpServerResponse.json({ status: result.status }); }),};GetCodeInterpreterSession
Section titled “GetCodeInterpreterSession”Source:
src/AWS/BedrockAgentCore/GetCodeInterpreterSession.ts
Reads a code interpreter session’s configuration and status.
Bind a CodeInterpreter inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.GetCodeInterpreterSessionHttp
on the Function effect to implement the binding.
GetCodeInterpreterSession: Inspecting Sessions
Section titled “GetCodeInterpreterSession: Inspecting Sessions”// initconst getCodeInterpreterSession = yield* AgentCore.GetCodeInterpreterSession(codeInterpreter);
return { fetch: Effect.gen(function* () { // runtime const result = yield* getCodeInterpreterSession({ sessionId }); return HttpServerResponse.json({ status: result.status }); }),};GetEvent
Section titled “GetEvent”Source:
src/AWS/BedrockAgentCore/GetEvent.ts
Fetches a single short-term event from an actor’s session.
Bind a Memory inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.GetEventHttp
on the Function effect to implement the binding.
GetEvent: Reading Events
Section titled “GetEvent: Reading Events”// initconst getEvent = yield* AgentCore.GetEvent(memory);
return { fetch: Effect.gen(function* () { // runtime const result = yield* getEvent({ actorId: "user-1", sessionId: "session-1", eventId, }); return HttpServerResponse.json({ event: result.event }); }),};GetMemoryRecord
Section titled “GetMemoryRecord”Source:
src/AWS/BedrockAgentCore/GetMemoryRecord.ts
Fetches a single extracted long-term memory record.
Bind a Memory inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.GetMemoryRecordHttp
on the Function effect to implement the binding.
GetMemoryRecord: Reading Memory Records
Section titled “GetMemoryRecord: Reading Memory Records”// initconst getMemoryRecord = yield* AgentCore.GetMemoryRecord(memory);
return { fetch: Effect.gen(function* () { // runtime const result = yield* getMemoryRecord({ memoryRecordId }); return HttpServerResponse.json({ record: result.memoryRecord }); }),};InvokeAgentRuntime
Section titled “InvokeAgentRuntime”Source:
src/AWS/BedrockAgentCore/InvokeAgentRuntime.ts
Sends a request to an agent hosted in an AgentCore Runtime and receives the (optionally streaming) response.
Bind a Runtime inside a function runtime to invoke the hosted
agent with session isolation (requests with the same runtimeSessionId
land on the same sandbox). Provide AgentCore.InvokeAgentRuntimeHttp on
the Function effect to implement the binding.
InvokeAgentRuntime: Invoking an Agent
Section titled “InvokeAgentRuntime: Invoking an Agent”// initconst invoke = yield* AgentCore.InvokeAgentRuntime(runtime);
return { fetch: Effect.gen(function* () { // runtime const response = yield* invoke({ runtimeSessionId: "session-0000000000000000000000000000000001", payload: JSON.stringify({ prompt: "hello" }), }); return HttpServerResponse.json({ contentType: response.contentType }); }),};InvokeAgentRuntimeCommand
Section titled “InvokeAgentRuntimeCommand”Source:
src/AWS/BedrockAgentCore/InvokeAgentRuntimeCommand.ts
Runs a shell command inside an agent hosted in an AgentCore Runtime and streams back the command output.
Bind a Runtime inside a function runtime to execute commands in
the hosted agent’s sandbox (requests with the same runtimeSessionId
land on the same sandbox). Provide
AgentCore.InvokeAgentRuntimeCommandHttp on the Function effect to
implement the binding.
InvokeAgentRuntimeCommand: Invoking an Agent
Section titled “InvokeAgentRuntimeCommand: Invoking an Agent”// initconst invokeCommand = yield* AgentCore.InvokeAgentRuntimeCommand(runtime);
return { fetch: Effect.gen(function* () { // runtime const response = yield* invokeCommand({ runtimeSessionId: "session-0000000000000000000000000000000001", body: { command: "echo hello" }, }); const chunks = yield* Stream.runCollect(response.stream); return HttpServerResponse.json({ chunks: Array.from(chunks) }); }),};InvokeBrowser
Section titled “InvokeBrowser”Source:
src/AWS/BedrockAgentCore/InvokeBrowser.ts
Performs an OS-level browser action (mouse, keyboard, screenshot) in a session.
OS-level actions cover interactions the Chrome DevTools Protocol cannot reach — print dialogs, context menus, and JavaScript alerts.
Bind a BrowserCustom inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.InvokeBrowserHttp
on the Function effect to implement the binding.
InvokeBrowser: Browser Automation
Section titled “InvokeBrowser: Browser Automation”// initconst invokeBrowser = yield* AgentCore.InvokeBrowser(browser);
return { fetch: Effect.gen(function* () { // runtime const result = yield* invokeBrowser({ sessionId, action: { screenshot: {} }, }); return HttpServerResponse.json({ result: result.result }); }),};InvokeCodeInterpreter
Section titled “InvokeCodeInterpreter”Source:
src/AWS/BedrockAgentCore/InvokeCodeInterpreter.ts
Executes a tool (e.g. executeCode) inside a code interpreter session.
The response carries a result stream.
Bind a CodeInterpreter inside a function runtime and call it with
a session id obtained from StartCodeInterpreterSession. Provide
AgentCore.InvokeCodeInterpreterHttp on the Function effect to implement
the binding.
InvokeCodeInterpreter: Executing Code
Section titled “InvokeCodeInterpreter: Executing Code”// initconst invoke = yield* AgentCore.InvokeCodeInterpreter(interpreter);
// runtime (inside the handler, with an open session)const result = yield* invoke({ sessionId: session.sessionId, name: "executeCode", arguments: { language: "python", code: "print(21 * 2)" },});const chunks = yield* Stream.runCollect(result.stream);ListActors
Section titled “ListActors”Source:
src/AWS/BedrockAgentCore/ListActors.ts
Lists the actors that have recorded events in the memory.
Bind a Memory inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.ListActorsHttp
on the Function effect to implement the binding.
ListActors: Listing Actors
Section titled “ListActors: Listing Actors”// initconst listActors = yield* AgentCore.ListActors(memory);
return { fetch: Effect.gen(function* () { // runtime const result = yield* listActors({}); return HttpServerResponse.json({ count: result.actorSummaries.length, }); }),};ListBrowserSessions
Section titled “ListBrowserSessions”Source:
src/AWS/BedrockAgentCore/ListBrowserSessions.ts
Lists the browser’s sessions.
Bind a BrowserCustom inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.ListBrowserSessionsHttp
on the Function effect to implement the binding.
ListBrowserSessions: Browser Sessions
Section titled “ListBrowserSessions: Browser Sessions”// initconst listBrowserSessions = yield* AgentCore.ListBrowserSessions(browser);
return { fetch: Effect.gen(function* () { // runtime const result = yield* listBrowserSessions({}); return HttpServerResponse.json({ count: result.items?.length ?? 0 }); }),};ListCodeInterpreterSessions
Section titled “ListCodeInterpreterSessions”Source:
src/AWS/BedrockAgentCore/ListCodeInterpreterSessions.ts
Lists the code interpreter’s sessions.
Bind a CodeInterpreter inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.ListCodeInterpreterSessionsHttp
on the Function effect to implement the binding.
ListCodeInterpreterSessions: Inspecting Sessions
Section titled “ListCodeInterpreterSessions: Inspecting Sessions”// initconst listCodeInterpreterSessions = yield* AgentCore.ListCodeInterpreterSessions(codeInterpreter);
return { fetch: Effect.gen(function* () { // runtime const result = yield* listCodeInterpreterSessions({}); return HttpServerResponse.json({ count: result.items?.length ?? 0 }); }),};ListEvents
Section titled “ListEvents”Source:
src/AWS/BedrockAgentCore/ListEvents.ts
Lists the events of an actor’s session in a memory’s short-term store.
Bind a Memory inside a function runtime to page through the raw
events recorded with CreateEvent. Provide AgentCore.ListEventsHttp on
the Function effect to implement the binding.
ListEvents: Listing Events
Section titled “ListEvents: Listing Events”// initconst listEvents = yield* AgentCore.ListEvents(memory);
return { fetch: Effect.gen(function* () { // runtime const result = yield* listEvents({ actorId: "user-1", sessionId: "session-1", }); return HttpServerResponse.json({ count: result.events.length }); }),};ListMemoryExtractionJobs
Section titled “ListMemoryExtractionJobs”Source:
src/AWS/BedrockAgentCore/ListMemoryExtractionJobs.ts
Lists the memory’s long-term extraction jobs.
Bind a Memory inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.ListMemoryExtractionJobsHttp
on the Function effect to implement the binding.
ListMemoryExtractionJobs: Extraction Jobs
Section titled “ListMemoryExtractionJobs: Extraction Jobs”// initconst listMemoryExtractionJobs = yield* AgentCore.ListMemoryExtractionJobs(memory);
return { fetch: Effect.gen(function* () { // runtime const result = yield* listMemoryExtractionJobs({}); return HttpServerResponse.json({ count: result.jobs.length, }); }),};ListMemoryRecords
Section titled “ListMemoryRecords”Source:
src/AWS/BedrockAgentCore/ListMemoryRecords.ts
Lists extracted long-term memory records in a namespace.
Bind a Memory inside a function runtime to enumerate the records
the memory’s strategies (semantic, summary, user preference, …) have
extracted into a namespace. Provide AgentCore.ListMemoryRecordsHttp on
the Function effect to implement the binding.
ListMemoryRecords: Listing Memory Records
Section titled “ListMemoryRecords: Listing Memory Records”// initconst listMemoryRecords = yield* AgentCore.ListMemoryRecords(memory);
return { fetch: Effect.gen(function* () { // runtime const result = yield* listMemoryRecords({ namespace: "facts/user-1", }); return HttpServerResponse.json({ count: result.memoryRecordSummaries.length, }); }),};ListSessions
Section titled “ListSessions”Source:
src/AWS/BedrockAgentCore/ListSessions.ts
Lists an actor’s sessions in a memory.
Bind a Memory inside a function runtime to enumerate the sessions
an actor has recorded events under. Provide AgentCore.ListSessionsHttp
on the Function effect to implement the binding.
ListSessions: Listing Sessions
Section titled “ListSessions: Listing Sessions”// initconst listSessions = yield* AgentCore.ListSessions(memory);
return { fetch: Effect.gen(function* () { // runtime const result = yield* listSessions({ actorId: "user-1" }); return HttpServerResponse.json({ count: result.sessionSummaries.length, }); }),};Memory
Section titled “Memory”Source:
src/AWS/BedrockAgentCore/Memory.ts
An Amazon Bedrock AgentCore Memory — managed short- and long-term memory for AI agents.
Short-term memory stores raw session events (turn-by-turn conversation);
optional memoryStrategies asynchronously extract long-term records
(semantic facts, summaries, user preferences) into queryable namespaces.
Provisioning is asynchronous: the provider waits for the memory to reach
ACTIVE (~2-3 minutes) before returning.
Memory: Creating Memories
Section titled “Memory: Creating Memories”Short-Term Memory Only
import * as AgentCore from "alchemy/AWS/BedrockAgentCore";
const memory = yield* AgentCore.Memory("SessionMemory", { eventExpiryDuration: "30 days",});Memory with a Semantic Long-Term Strategy
const memory = yield* AgentCore.Memory("AgentMemory", { eventExpiryDuration: "90 days", memoryStrategies: [ { semanticMemoryStrategy: { name: "facts", namespaces: ["facts/{actorId}"], }, }, ],});Memory: Using Memory from a Function
Section titled “Memory: Using Memory from a Function”// initconst createEvent = yield* AgentCore.CreateEvent(memory);const listEvents = yield* AgentCore.ListEvents(memory);
return { fetch: Effect.gen(function* () { // runtime yield* createEvent({ actorId: "user-1", sessionId: "session-1", eventTimestamp: new Date(), payload: [ { conversational: { role: "USER", content: { text: "My favorite color is teal." }, }, }, ], }); const events = yield* listEvents({ actorId: "user-1", sessionId: "session-1", }); return HttpServerResponse.json({ count: events.events.length }); }),};RetrieveMemoryRecords
Section titled “RetrieveMemoryRecords”Source:
src/AWS/BedrockAgentCore/RetrieveMemoryRecords.ts
Semantically searches extracted long-term memory records.
Bind a Memory inside a function runtime to run relevance-ranked
queries over the records the memory’s long-term strategies have extracted.
Provide AgentCore.RetrieveMemoryRecordsHttp on the Function effect to
implement the binding.
RetrieveMemoryRecords: Retrieving Memory Records
Section titled “RetrieveMemoryRecords: Retrieving Memory Records”// initconst retrieveMemoryRecords = yield* AgentCore.RetrieveMemoryRecords(memory);
return { fetch: Effect.gen(function* () { // runtime const result = yield* retrieveMemoryRecords({ namespace: "facts/user-1", searchCriteria: { searchQuery: "what is the user's favorite color?", topK: 3, }, }); return HttpServerResponse.json({ records: result.memoryRecordSummaries, }); }),};Runtime
Section titled “Runtime”Source:
src/AWS/BedrockAgentCore/Runtime.ts
An Amazon Bedrock AgentCore Runtime — serverless hosting for containerized AI agents.
A runtime deploys an agent (an ECR container image or managed-runtime code
bundle) behind the InvokeAgentRuntime data-plane API with session
isolation, scaling, and identity built in. Each configuration change
publishes a new immutable runtime version.
Runtime: Creating Runtimes
Section titled “Runtime: Creating Runtimes”import * as AgentCore from "alchemy/AWS/BedrockAgentCore";
const runtime = yield* AgentCore.Runtime("MyAgent", { agentRuntimeArtifact: { containerConfiguration: { containerUri: `${account}.dkr.ecr.us-west-2.amazonaws.com/my-agent:latest`, }, }, roleArn: role.roleArn,});Runtime: Invoking from a Function
Section titled “Runtime: Invoking from a Function”// initconst invoke = yield* AgentCore.InvokeAgentRuntime(runtime);
return { fetch: Effect.gen(function* () { // runtime const response = yield* invoke({ runtimeSessionId: "session-0000000000000000000000000000000001", payload: JSON.stringify({ prompt: "hello" }), }); return HttpServerResponse.json({ contentType: response.contentType }); }),};SaveBrowserSessionProfile
Section titled “SaveBrowserSessionProfile”Source:
src/AWS/BedrockAgentCore/SaveBrowserSessionProfile.ts
Persists a browser session’s state to a reusable browser profile.
Bind a BrowserCustom inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.SaveBrowserSessionProfileHttp
on the Function effect to implement the binding.
SaveBrowserSessionProfile: Browser Profiles
Section titled “SaveBrowserSessionProfile: Browser Profiles”// initconst saveBrowserSessionProfile = yield* AgentCore.SaveBrowserSessionProfile(browser);
return { fetch: Effect.gen(function* () { // runtime yield* saveBrowserSessionProfile({ sessionId, profileIdentifier, }); return HttpServerResponse.json({ saved: true }); }),};StartBrowserSession
Section titled “StartBrowserSession”Source:
src/AWS/BedrockAgentCore/StartBrowserSession.ts
Starts a managed, sandboxed browser session on a custom browser.
Bind a BrowserCustom inside a function runtime to open cloud
browser sessions for web automation; pair with GetBrowserSession,
InvokeBrowser, and StopBrowserSession. Provide
AgentCore.StartBrowserSessionHttp on the Function effect to implement
the binding.
StartBrowserSession: Browser Sessions
Section titled “StartBrowserSession: Browser Sessions”// initconst startBrowserSession = yield* AgentCore.StartBrowserSession(browser);const stopBrowserSession = yield* AgentCore.StopBrowserSession(browser);
return { fetch: Effect.gen(function* () { // runtime const session = yield* startBrowserSession({ sessionTimeout: "5 minutes", }); yield* stopBrowserSession({ sessionId: session.sessionId }); return HttpServerResponse.json({ sessionId: session.sessionId }); }),};StartCodeInterpreterSession
Section titled “StartCodeInterpreterSession”Source:
src/AWS/BedrockAgentCore/StartCodeInterpreterSession.ts
Starts an isolated code-execution session on a code interpreter.
Bind a CodeInterpreter inside a function runtime to open sandboxed
sessions; pair with InvokeCodeInterpreter to run code in the session and
StopCodeInterpreterSession to end it. Provide
AgentCore.StartCodeInterpreterSessionHttp on the Function effect to
implement the binding.
StartCodeInterpreterSession: Running Code
Section titled “StartCodeInterpreterSession: Running Code”// initconst startSession = yield* AgentCore.StartCodeInterpreterSession(interpreter);const invoke = yield* AgentCore.InvokeCodeInterpreter(interpreter);const stopSession = yield* AgentCore.StopCodeInterpreterSession(interpreter);
return { fetch: Effect.gen(function* () { // runtime const session = yield* startSession({ sessionTimeout: "5 minutes" }); const result = yield* invoke({ sessionId: session.sessionId, name: "executeCode", arguments: { language: "python", code: "print(21 * 2)" }, }); const chunks = yield* Stream.runCollect(result.stream); yield* stopSession({ sessionId: session.sessionId }); return HttpServerResponse.json({ chunks: Array.from(chunks) }); }),};StartMemoryExtractionJob
Section titled “StartMemoryExtractionJob”Source:
src/AWS/BedrockAgentCore/StartMemoryExtractionJob.ts
Starts an on-demand long-term extraction job over recorded events.
Bind a Memory inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.StartMemoryExtractionJobHttp
on the Function effect to implement the binding.
StartMemoryExtractionJob: Extraction Jobs
Section titled “StartMemoryExtractionJob: Extraction Jobs”// initconst startMemoryExtractionJob = yield* AgentCore.StartMemoryExtractionJob(memory);
return { fetch: Effect.gen(function* () { // runtime const result = yield* startMemoryExtractionJob({ extractionJob: { jobId }, }); return HttpServerResponse.json({ jobId: result.jobId }); }),};StopBrowserSession
Section titled “StopBrowserSession”Source:
src/AWS/BedrockAgentCore/StopBrowserSession.ts
Terminates an active browser session.
Bind a BrowserCustom inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.StopBrowserSessionHttp
on the Function effect to implement the binding.
StopBrowserSession: Browser Sessions
Section titled “StopBrowserSession: Browser Sessions”// initconst stopBrowserSession = yield* AgentCore.StopBrowserSession(browser);
return { fetch: Effect.gen(function* () { // runtime yield* stopBrowserSession({ sessionId }); return HttpServerResponse.json({ stopped: true }); }),};StopCodeInterpreterSession
Section titled “StopCodeInterpreterSession”Source:
src/AWS/BedrockAgentCore/StopCodeInterpreterSession.ts
Stops a running code interpreter session.
Bind a CodeInterpreter inside a function runtime to end sessions
opened with StartCodeInterpreterSession and release the sandbox.
Provide AgentCore.StopCodeInterpreterSessionHttp on the Function effect
to implement the binding.
StopCodeInterpreterSession: Stopping Sessions
Section titled “StopCodeInterpreterSession: Stopping Sessions”// initconst stopSession = yield* AgentCore.StopCodeInterpreterSession(interpreter);
// runtime (inside the handler)yield* stopSession({ sessionId: session.sessionId });StopRuntimeSession
Section titled “StopRuntimeSession”Source:
src/AWS/BedrockAgentCore/StopRuntimeSession.ts
Stops a specific session on the agent runtime.
Bind a Runtime inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.StopRuntimeSessionHttp
on the Function effect to implement the binding.
StopRuntimeSession: Runtime Sessions
Section titled “StopRuntimeSession: Runtime Sessions”// initconst stopRuntimeSession = yield* AgentCore.StopRuntimeSession(runtime);
return { fetch: Effect.gen(function* () { // runtime yield* stopRuntimeSession({ runtimeSessionId }); return HttpServerResponse.json({ stopped: true }); }),};UpdateBrowserStream
Section titled “UpdateBrowserStream”Source:
src/AWS/BedrockAgentCore/UpdateBrowserStream.ts
Updates a browser session’s automation stream.
Bind a BrowserCustom inside a function runtime to call the
AgentCore data-plane API against it. Provide AgentCore.UpdateBrowserStreamHttp
on the Function effect to implement the binding.
UpdateBrowserStream: Browser Automation
Section titled “UpdateBrowserStream: Browser Automation”// initconst updateBrowserStream = yield* AgentCore.UpdateBrowserStream(browser);
return { fetch: Effect.gen(function* () { // runtime yield* updateBrowserStream({ sessionId, streamUpdate: { automationStreamUpdate: { streamStatus: "ENABLED" }, }, }); return HttpServerResponse.json({ updated: true }); }),};