Skip to content

Add llama-index-tools-heroku integration#20606

Open
dsouza-anush wants to merge 1 commit intorun-llama:mainfrom
dsouza-anush:add-heroku-tools
Open

Add llama-index-tools-heroku integration#20606
dsouza-anush wants to merge 1 commit intorun-llama:mainfrom
dsouza-anush:add-heroku-tools

Conversation

@dsouza-anush
Copy link

Summary

Adds llama-index-tools-heroku package for Heroku Agents API tool integration.

Description

This integration enables LlamaIndex agents to execute SQL queries, run Python/JavaScript code, and interact with Heroku apps through the Heroku Agents API.

Features

  • HerokuToolSpec class extending LlamaIndex BaseToolSpec
  • run_sql - Execute SQL queries on Heroku Postgres
  • run_python - Execute Python code in sandboxed environment
  • run_javascript - Execute JavaScript code in sandboxed environment
  • get_app_info - Get Heroku app metadata
  • Compatible with ReActAgent and FunctionCallingAgent

Usage

from llama_index.tools.heroku import HerokuToolSpec, create_heroku_tools
from llama_index.core.agent import ReActAgent
from llama_index.llms.heroku import Heroku

# Create tools
tools = create_heroku_tools(
    api_key="your-heroku-inference-key",
    app_name="your-heroku-app",
)

# Create agent
llm = Heroku(model="claude-4-sonnet", api_key=api_key)
agent = ReActAgent.from_tools(tools, llm=llm)

# Use naturally
response = agent.chat("Count the users in the database")

Testing

  • 13 unit tests with mocked HTTP responses

Related

🤖 Generated with Claude Code

Adds agent tools for Heroku Agents API integration.

Features:
- HerokuToolSpec class with SQL, Python, and JavaScript execution
- Integration with Heroku Agents API
- Compatible with LlamaIndex ReActAgent and FunctionCallingAgent

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Feb 1, 2026
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as per the rerank integration, you should use uv + hatchling and not poetry in the pyproject

return self._call_agent_tool("app_info", {})


def create_heroku_tools(
Copy link
Member

Choose a reason for hiding this comment

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

nit on naming: maybe get_heroku_tools is better

Comment on lines +82 to +109
async def _acall_agent_tool(self, tool_name: str, tool_input: dict) -> str:
"""Async call a Heroku Agents API tool.

Args:
tool_name: The name of the tool to call.
tool_input: The input parameters for the tool.

Returns:
The tool execution result as a string.
"""
response = await self._async_client.post(
f"{self.base_url}/v1/agents/heroku",
headers=self._get_headers(),
json={
"app_name": self.app_name,
"tool_choice": {
"type": "tool",
"name": tool_name,
},
"tool_input": tool_input,
},
)
response.raise_for_status()

result = response.json()
if "error" in result:
return f"Error: {result['error']}"
return result.get("output", str(result))
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for having an async method? I don't see it used in the class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants