Skip to content

Conversation

@michaelnchin
Copy link
Contributor

@michaelnchin michaelnchin commented Jul 30, 2025

Description

This PR adds a new llama-index-tools-aws-bedrock-agentcore tools integration package, which implements two new browser and code interpreter toolspecs built on the AWS Bedrock AgentCore API:

  • AgentCoreBrowserToolSpec: Enables agents to to navigate websites, extract content, click elements, and more.
  • AgentCoreCodeInterpreterToolSpec: Enables agents to execute code, run shell commands, manage files, and perform computational tasks.

Example Usage

Installation

pip install llama-index llama-index-llms-bedrock-converse;
pip install llama-index-tools-aws-bedrock-agentcore;

Browser Tools

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

async def main():
    tool_spec = AgentCoreBrowserToolSpec(region="us-west-2")
    tools = tool_spec.to_tool_list()

    llm = BedrockConverse(
        model="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
        region_name="us-west-2",
    )

    agent = FunctionAgent(
        tools=tools,
        llm=llm,
    )

    task = "Go to https://news.ycombinator.com/ and tell me the titles of the top 5 posts."

    response = await agent.run(task)
    print(str(response))

    await tool_spec.cleanup()

if __name__ == "__main__":
    asyncio.run(main())

Code Interpreter Tools

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

async def main():
    tool_spec = AgentCoreCodeInterpreterToolSpec(region="us-west-2")
    tools = tool_spec.to_tool_list()

    llm = BedrockConverse(
        model="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
        region_name="us-west-2",
    )

    agent = FunctionAgent(
        tools=tools,
        llm=llm,
    )

    code_task = "Write a Python function that calculates the factorial of a number and test it."

    code_response = await agent.run(code_task)
    print(str(code_response))

    await tool_spec.cleanup()

if __name__ == "__main__":
    asyncio.run(main())

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Jul 30, 2025
@michaelnchin michaelnchin changed the title [TEST] Bedrock AgentCore browser and code interpreter toolspecs Bedrock AgentCore browser and code interpreter toolspecs Jul 30, 2025
@michaelnchin michaelnchin reopened this Jul 30, 2025
Copy link
Collaborator

@logan-markewich logan-markewich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty great to me! Just a few comments

Does bedrock_agentcore support python3.9? Noticed some odd test failures

@michaelnchin
Copy link
Contributor Author

michaelnchin commented Aug 2, 2025

@logan-markewich, thank you for taking the time to review this! The PR has been updated for your feedback.

Does bedrock_agentcore support python3.9?

>=3.10 only - I've now upgraded the tools package to 3.10 floor to match this.

Copy link
Collaborator

@logan-markewich logan-markewich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This looks great, going to merge this

@logan-markewich logan-markewich merged commit 16f5c18 into run-llama:main Aug 4, 2025
11 checks passed
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 4, 2025
@michaelnchin michaelnchin deleted the bedrock-agentcore-browser-code-tools-rebase branch August 4, 2025 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants