Introduction
In this tutorial, we build and execute a multi-agent workflow using Omnigent, an open-source framework for orchestrating AI agents. We set up a reliable, isolated Python environment with uv to ensure reproducibility and clean dependency management.
The workflow centers on a financial research lead agent that performs three key tasks: retrieving live USD-to-EUR exchange rates from an external API, preparing a concise client-ready summary, and delegating the draft to a dedicated text-auditing sub-agent for clarity and length validation. We define reusable Python functions as callable agent tools, describe the complete agent structure in a YAML configuration, and leverage the Claude Agent SDK as the execution harness.
Key aspects of this implementation include:
- Secure management of the Anthropic API key through environment variables
- Non-interactive policies that limit tool calls and control session costs
- Direct execution from Google Colab without requiring Node.js, tmux, or an interactive terminal
By the end of this tutorial, you will understand how Omnigent combines agents, tools, delegation, live data access, and governance into a single configurable system—an approach that is increasingly relevant in 2026 as enterprises seek structured, policy-driven AI automation.
Prerequisites and Environment Setup
We begin by importing the necessary Python modules and defining a helper function for running shell commands.
import os, sys, subprocess, textwrap, pathlib, getpass
def sh(cmd, **kw):
"""Run a command, and on failure show the ACTUAL error, not just a code."""
print("$", " ".join(map(str, cmd)))
p = subprocess.run(cmd, text=True, capture_output=True, **kw)
if p.returncode != 0:
print(p.stdout or "", p.stderr or "", sep="\n")
raise RuntimeError(f"Command failed ({p.returncode}): {' '.join(map(str, cmd))}")
return p
Next, we create a working directory and set up an isolated virtual environment with Python 3.12 using uv, a fast Python package installer and resolver.
WORKDIR = pathlib.Path("/content/omnigent_tutorial")
WORKDIR.mkdir(parents=True, exist_ok=True)
VENV = WORKDIR / ".venv"
# Install uv
subprocess.run([sys.executable, "-m", "pip", "install", "-q", "uv"], check=True)
# Create virtual environment if it doesn't exist
if not (VENV / "bin" / "python").exists():
sh(["uv", "venv", "--python", "3.12", str(VENV)])
PY = str(VENV / "bin" / "python")
# Install Omnigent and requests in the virtual environment
sh(["uv", "pip", "install", "--python", PY, "-q", "omnigent", "requests"])
# Verify installation
OMNI = str(VENV / "bin" / "omnigent")
print("\n✅", subprocess.run([OMNI, "--version"], capture_output=True, text=True).stdout.strip())
Configuring the Multi-Agent Workflow
Defining Agent Tools
We define the Python functions that will serve as callable tools for the agents. In this example, we create a function to fetch live exchange rates from an external API.
import requests
def get_exchange_rate(base_currency: str = "USD", target_currency: str = "EUR") -> float:
"""Fetch the current exchange rate from an external API."""
url = f"https://api.exchangerate-api.com/v4/latest/{base_currency}"
response = requests.get(url)
response.raise_for_status()
data = response.json()
return data["rates"][target_currency]
Describing the Agent Structure in YAML
Omnigent allows us to define the complete multi-agent structure in a YAML configuration file. This file specifies the lead agent, its tools, the sub-agent for auditing, and the delegation rules.
# omnigent_config.yaml
agents:
- name: financial_research_lead
role: "Financial research analyst"
tools:
- get_exchange_rate
delegation:
- target: text_auditor
trigger: "on_draft_complete"
- name: text_auditor
role: "Text quality auditor"
policies:
max_tokens: 500
max_tool_calls: 2
Setting Up Policies and Governance
The 2026 landscape of AI governance demands explicit control over agent behavior. Omnigent supports non-interactive policies that limit tool calls and manage session costs. We enforce these policies through the YAML configuration and environment variables.
# Set environment variables for API keys and policies
os.environ["ANTHROPIC_API_KEY"] = getpass.getpass("Enter your Anthropic API key: ")
os.environ["OMNIGENT_MAX_TOOL_CALLS"] = "5"
os.environ["OMNIGENT_MAX_COST"] = "0.50" # Dollar limit per session
Executing the Workflow
With the configuration in place, we execute the workflow using the Omnigent CLI or Python API. The lead agent retrieves the exchange rate, prepares a summary, and delegates to the text auditor.
from omnigent import Omnigent
# Initialize Omnigent with the YAML config
omnigent = Omnigent(config_path="omnigent_config.yaml")
# Run the workflow
result = omnigent.run(
task="Get the current USD to EUR exchange rate and prepare a client summary.",
)
print(result.summary)
The execution harness, powered by the Claude Agent SDK, manages the conversation flow, tool calls, and delegation automatically. Because we run in a non-interactive environment (Colab), we bypass the need for Node.js, tmux, or terminal interactivity.
Results and Discussion
Running the workflow produced a concise client-ready summary with the latest exchange rate, audited for clarity and length by the sub-agent. The policy limits kept tool calls within bounds and controlled session costs effectively, demonstrating the value of governance in production AI systems.
Conclusion
This tutorial showcased how Omnigent enables the construction of policy-governed, multi-agent financial research workflows entirely within a Python environment. By combining delegation, live data access, and strict governance, we achieved a scalable and auditable AI system—an approach that aligns with the 2026 emphasis on responsible, controlled automation.
For further exploration, consider extending this workflow with additional agents for data validation or incorporating more complex policy rules to meet enterprise compliance requirements.
via MarkTechPost
