AI Agents in Graph Compose ๐Ÿค–

๐Ÿš€ Beta Feature!

Supercharge your workflows with intelligent agents that can think, decide, and act! Within Graph Compose, agents function as specialized workflow nodes that interact via a specific contract. You implement and host the agent's logic at your own HTTP endpoint. As long as your endpoint follows this contract, the agent node can iteratively use defined tools, also defined as HTTP endpoints, (up to a maximum iteration count) to gather information and perform actions before completing its task within the workflow.

View Complete Agent Node Schema

What are AI Agents in Graph Compose? ๐Ÿค”

Think of agents as powerful workflow nodes that can:

  • ๐Ÿ”„ Execute other nodes iteratively to solve complex tasks
  • ๐Ÿง  Make decisions based on tool results
  • ๐Ÿ› ๏ธ Use HTTP and graph-based tools
  • ๐ŸŽฏ Determine when a task is complete

Unlike regular nodes or standard workflow graphs which follow predetermined execution paths, agent nodes operate more dynamically. Because agents determine how and which subsequent nodes (tools) to execute based on the current state and previous results, they can effectively take alternative paths to accomplish their objective.

Our Philosophy: Agents as Workflow Nodes

Many frameworks require significant "buy-in," forcing you to adopt specific abstractions or infrastructure just to integrate agents. We believe this is often unnecessary. At their core, many agentic processes involve a loop of: receiving state, processing it (perhaps with an LLM prompt), and deciding whether to call a tool or finish.

Graph Compose's node-based orchestration is naturally suited for this pattern without requiring framework lock-in. We treat agents simply as specialized nodes within your workflow graph. Here's our approach:

  • You Own the Agent Logic: Your agent is an HTTP endpoint that you build, host, and control completely. Use any AI model, framework, or logic you prefer. Graph Compose doesn't impose specific AI implementations.
  • Simple Contract: Your agent endpoint just needs to adhere to a straightforward request/response contract. It receives the current workflow state (including results from previous nodes and tools) and responds with the next action: either call a specific tool or signal completion.
  • Tools are Nodes: When your agent decides to call a tool, it's instructing Graph Compose to execute another node (defined as a tool) within the same workflow graph. This seamlessly integrates agent actions with the rest of your workflow's logic, state, and reliability features.
  • Iterative Execution: Graph Compose manages the agent loop, sending state to your endpoint, executing the requested tool node, providing the result back to your agent, and enforcing the max_iterations limit.
  • Production Ready Orchestration: Built-in durability, monitoring, and error handling come standard for the workflow orchestration layer.

Quick Example

Let's look at how to define an agent in your workflow. This example shows a research agent that can search for information and process the results:

import { GraphCompose } from '@graph-compose/client'

const workflow = new GraphCompose()
  // Define a research agent that can use search and processing tools
  .agent("research_agent") // Creates an agent node directly
    .post("https://api.example.com/agents/research")
    .withMaxIterations(5) // Limit the number of iterations
    .withTools(["search_api", "process_data"])  // Tools this agent can use
  .end()
  
  // Define the tools our agent can use
  .tool("search_api")  // A simple HTTP tool for searching
    .get("https://api.search.com/search")
  .end()
  
  .tool("process_data")  // A more complex tool using a sub-workflow
    .graph(graph => graph
      .node("process")
        .post("https://api.process.com/analyze")
      .end()
    )
  .end();

// Execute the workflow
const result = await workflow.execute();

Next Steps

Further Reading