Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.stackone.com/llms.txt

Use this file to discover all available pages before exploring further.

Build AI agents using LangChain’s framework with direct access to business data through StackOne’s infrastructure of pre-built tools, RPC orchestration, and MCP/A2A interfaces.

Overview

  • ReAct and OpenAI Functions agents with business tool access
  • Multi-step workflow automation
  • Conversational agents with memory
  • Advanced error handling and resilience
from stackone_ai import StackOneToolSet
from langchain_openai import ChatOpenAI

def create_agent_for_account(account_id: str):
    """
    Create LangChain agent with tools for a specific account.

    In production, account_id comes from:
    - User/tenant context
    - Authentication middleware
    - Request parameters
    """
    # Initialize toolset
    toolset = StackOneToolSet()

    # Fetch tools dynamically for this account
    tools = toolset.fetch_tools(account_ids=[account_id])
    langchain_tools = tools.to_langchain()

    # Create model with tools
    model = ChatOpenAI(model="gpt-5.4")
    model_with_tools = model.bind_tools(langchain_tools)

    return model_with_tools, tools

# Usage: Get account from user context
# Get account ID from your app's auth context or StackOne dashboard
account_id = "your-account-id"
model, tools = create_agent_for_account(account_id)

# Use the agent
response = model.invoke("List all employees in engineering")

# Handle tool execution
for tool_call in response.tool_calls:
    tool = tools.get_tool(tool_call["name"])
    if tool:
        result = tool.execute(tool_call["args"])
        print(f"Result: {result}")

Example

Let the LLM discover tools on its own. LangChain handles tool execution automatically:
from langchain_openai import ChatOpenAI
from stackone_ai import StackOneToolSet

toolset = StackOneToolSet(
    search={"method": "semantic", "top_k": 3},
    execute={"account_ids": ["your-account-id"]},
)

# LLM receives only 2 tools - framework handles execution
langchain_tools = toolset.langchain(mode="search_and_execute")
model = ChatOpenAI(model="gpt-5.4").bind_tools(langchain_tools)

response = model.invoke(messages)
See Tool Search for the full agent loop example.

Next Steps