Skill

Deploy LlamaIndex Agents to Bedrock AgentCore

Deploy LlamaIndex agents to Amazon Bedrock AgentCore Runtime with sandboxed browser and code-execution tools.

Works with aws bedrockllama index

92
Spark score
out of 100
Updated 15 days ago
Version 0.14.23
Models

Add to Favorites

Why it matters

Deploy and manage LlamaIndex agents on Amazon Bedrock AgentCore Runtime. This asset provides a managed compute platform for your AI agents, enabling them to interact with sandboxed browser environments and execute code.

Outcomes

What it gets done

01

Deploy LlamaIndex agents to AWS Bedrock AgentCore Runtime.

02

Enable agents to perform sandboxed browser automation.

03

Integrate agents with code execution capabilities.

04

Manage agent memory and session context.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-tool-tools-aws-bedrock-agentcore | bash

Overview

Amazon Bedrock AgentCore Runtime and Tools

A runtime adapter and toolset for deploying LlamaIndex agents onto Amazon Bedrock AgentCore's managed compute, plus toolspecs for sandboxed browser automation and code execution. Use it when you need to host a LlamaIndex agent on AgentCore's managed runtime with streaming and memory, or give it sandboxed browser/code-execution tools. Requires AWS credentials and bedrock-agentcore:* IAM permissions.

What it does

llama-index-tools-aws-bedrock-agentcore provides a runtime adapter plus toolspecs for deploying and extending LlamaIndex agents with Amazon Bedrock AgentCore - a managed compute platform for AI agents, sandboxed browser automation, and code execution. The AgentCoreRuntime adapter wraps BedrockAgentCoreApp from the bedrock-agentcore SDK, exposing the POST /invocations and GET /ping endpoints AgentCore Runtime requires, so a plain FunctionAgent can be deployed with a one-line AgentCoreRuntime.serve(agent) call that starts a uvicorn server on port 8080. On top of the runtime, the module also ships a Browser toolspec that lets an agent navigate, click, and extract content from web pages inside a secure sandbox.

When to use - and when NOT to

Use this module when you want to run a LlamaIndex agent as a managed, scalable service on AWS rather than hosting it yourself, especially if you also want SSE streaming, session-scoped memory, or sandboxed browser/code-execution tools alongside it. It requires AWS credentials (via environment variables, AWS CLI profile, or IAM role), IAM permissions for bedrock-agentcore:* actions, and Python 3.9+ - so it isn't a fit outside an AWS account with AgentCore access configured.

Inputs and outputs

The runtime accepts a JSON payload with a prompt, message, or input key over POST /invocations:

curl -X POST http://localhost:8080/invocations \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Hello, what can you do?"}'

When stream=True (the default), it emits an SSE stream of typed events - agent_stream (token-by-token output), tool_call (before a tool runs), tool_result (after a tool runs), done (the final response), and error - rather than one final JSON body.

Integrations

Pair the runtime with AgentCoreMemory (from llama-index-memory-bedrock-agentcore) to persist conversation state by session: give it a memory_id and actor_id, and the runtime automatically wires the session ID from the X-Amzn-Bedrock-AgentCore-Runtime-Session-Id header into memory. The Browser toolspec adds tools such as navigate_browser (go to a URL) and click_element (click an element by CSS selector) for sandboxed web interaction. Install with pip install llama-index-tools-aws-bedrock-agentcore, plus llama-index-llms-bedrock-converse if you also want to run the BedrockConverse LLM examples. Beyond the one-line serve() call, AgentCoreRuntime also accepts explicit options - stream (SSE streaming, on by default), port (the port AgentCore deployment requires), and debug - via runtime.run(), and exposes its underlying Starlette-based app as runtime.app for ASGI-level testing with a client such as httpx.AsyncClient.

Who it's for

Teams already running LlamaIndex agents on AWS who want a managed runtime with streaming and memory instead of self-hosting, plus sandboxed browser or code-execution capability for agents that need to interact with the live web.

Source README

Amazon Bedrock AgentCore Runtime and Tools

This module provides a runtime adapter and tools for deploying and extending LlamaIndex agents with Amazon Bedrock AgentCore -- including managed compute via AgentCore Runtime, sandboxed browser automation, and code execution.

Prerequisites

  • AWS credentials configured via environment variables, AWS CLI profile, or IAM role
  • IAM permissions for bedrock-agentcore:* actions (see the AgentCore documentation for details)
  • Python 3.9+

Installation

(Optional) To run the examples below, first install:

pip install llama-index llama-index-llms-bedrock-converse

Install the main tools package:

pip install llama-index-tools-aws-bedrock-agentcore

Runtime

The AgentCoreRuntime adapter deploys any LlamaIndex agent to Amazon Bedrock AgentCore Runtime -- a managed compute platform for AI agents. It wraps BedrockAgentCoreApp from the bedrock-agentcore SDK, providing the required POST /invocations and GET /ping endpoints.

Quick Start

from llama_index.llms.bedrock_converse import BedrockConverse
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.tools.aws_bedrock_agentcore import AgentCoreRuntime

llm = BedrockConverse(
    model="us.anthropic.claude-sonnet-4-6-v1",
    region_name="us-west-2",
)
agent = FunctionAgent(llm=llm, tools=[])

### One-liner -- starts uvicorn on port 8080
AgentCoreRuntime.serve(agent)

With Options

runtime = AgentCoreRuntime(
    agent=agent,
    stream=True,  # SSE streaming (default)
    port=8080,  # Required port for AgentCore deployment
    debug=False,
)
runtime.run()

With AgentCore Memory

from llama_index.memory.bedrock_agentcore import (
    AgentCoreMemory,
    AgentCoreMemoryContext,
)

memory = AgentCoreMemory(
    context=AgentCoreMemoryContext(
        memory_id="your-memory-id",
        actor_id="user-123",
    ),
    region_name="us-west-2",
)

### Session ID from the X-Amzn-Bedrock-AgentCore-Runtime-Session-Id header
### is automatically wired to memory
AgentCoreRuntime.serve(agent, memory=memory)

Sending Requests

### Non-streaming
curl -X POST http://localhost:8080/invocations \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Hello, what can you do?"}'

### Streaming (SSE)
curl -N -X POST http://localhost:8080/invocations \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Hello, what can you do?"}'

The adapter accepts prompt, message, or input as the payload key.

Streaming Event Types

When stream=True (default), the SSE stream emits these event types:

Event Fields Description
agent_stream delta, response, thinking_delta? Token-by-token LLM output
tool_call tool_name, tool_kwargs Before tool execution
tool_result tool_name, tool_output After tool execution
done response Final agent response
error message Error during streaming

Testing with ASGI

runtime = AgentCoreRuntime(agent=agent)
app = runtime.app  # BedrockAgentCoreApp (Starlette-based)
### Use with httpx.AsyncClient for testing

Toolspecs

Browser

The AgentCore Browser toolspec provides a set of tools for interacting with web browsers in a secure sandbox environment. It enables your LlamaIndex agents to navigate websites, extract content, click elements, and more.

Included tools:

  • navigate_browser: Navigate to a URL
  • click_element: Click on an element using CSS sele

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.