Skip to main content

Delfhos — AI agent SDK with typed connections and tool orchestration

Project description

Delfhos

Python SDK for building AI agents that use real tools — Gmail, SQL, Drive, Sheets, MCP servers, and your own functions — with safe, human-in-the-loop execution.

Full documentation at delfhos.com/docs


How it works

You describe a task in plain English. Delfhos:

  1. Picks the relevant tools from the ones you configured
  2. Writes Python code to accomplish the task
  3. Executes that code in a sandbox against your real services
  4. Retries automatically if something fails

You stay in control: restrict which actions each tool can take, and require approval before any write, send, or delete.


Install

pip install delfhos

API Key

Delfhos supports Gemini, OpenAI, and Anthropic models. Export the key for the provider you want to use:

export GOOGLE_API_KEY="..."    # Gemini
export OPENAI_API_KEY="..."    # OpenAI
export ANTHROPIC_API_KEY="..."  # Claude

Try it instantly (no credentials needed)

The sandbox tools come pre-loaded with dummy data so you can run your first agent right now:

from delfhos import Agent
from delfhos.sandbox import MockEmail, MockDatabase

agent = Agent(
    tools=[MockEmail(confirm=False), MockDatabase(confirm=False)],
    llm="gemini-3.1-flash-lite-preview",
)

agent.run(
    "Read my unread emails. If any mention a support ticket, "
    "look it up in the database and summarise the customer name, "
    "open tickets, and total order value."
)
agent.stop()

Or just run the included example:

python examples/hello_delfhos.py

Custom tools

Decorate any Python function with @tool and the agent can call it:

from delfhos import Agent, tool

@tool
def calculate_discount(price: float, pct: float) -> float:
    """Return price after applying a percentage discount."""
    return price * (1 - pct / 100)

agent = Agent(tools=[calculate_discount], llm="gemini-3.1-flash-lite-preview")
agent.run("What is the price of a $120 item with a 15% discount?")
agent.stop()

Built-in tools

from delfhos import Gmail, SQL, Sheets, Drive, Calendar, Docs, WebSearch, MCP
gmail = Gmail(oauth_credentials="client_secrets.json", allow=["read", "send"], confirm=["send"])
db    = SQL(url="postgresql://user:pass@host/db",       allow=["schema", "query"])
drive = Drive(oauth_credentials="client_secrets.json",  confirm=True)

agent = Agent(tools=[gmail, db, drive], llm="gemini-3.1-flash-lite-preview")
agent.run("Check unread emails and log any order mentions to the database.")
agent.stop()

allow — restrict which actions are available on the tool (["read", "send"], ["schema", "query"], …).
confirm — when human approval is required: True (all), False (none), or a list of specific actions.


Interactive chat

from delfhos import Agent, Chat, Gmail

agent = Agent(
    tools=[Gmail(oauth_credentials="client_secrets.json")],
    llm="gemini-3.1-flash-lite-preview",
    chat=Chat(summarizer_llm="gemini-3.1-flash-lite-preview"),
)

agent.run_chat()  # starts a terminal session — type /help for commands

Memory

from delfhos import Agent, Chat, Memory

agent = Agent(
    tools=[...],
    llm="gemini-3.1-flash-lite-preview",
    chat=Chat(keep=8, summarize=True, namespace="my_agent"),    # short-term
    memory=Memory(namespace="my_agent"),                         # long-term semantic
)

Embedding Models: See EMBEDDING_MODELS_GUIDE.md for comprehensive guide to 100+ supported models with auto-detection of model-specific requirements (trust_remote_code, instruction prefixes, etc.).


MCP servers

from delfhos import Agent, MCP

fs = MCP("server-filesystem", args=["."], allow=["read_file", "write_file"])
agent = Agent(tools=[fs], llm="gemini-3.1-flash-lite-preview")
agent.run("List all Python files and write a one-line summary for each.")
agent.stop()

Response object

agent.run() returns a Response with the result, status, cost, and trace:

r = agent.run("How many users signed up this week?")

print(r.text)        # agent's answer
print(r.status)      # True if task succeeded
print(r.cost_usd)    # cost in dollars (e.g. 0.0003)
print(r.duration_ms) # wall-clock time in milliseconds

Model support

Pass any model string from Gemini, OpenAI, or Anthropic:

# Gemini
agent = Agent(tools=[...], llm="gemini-2.0-flash-lite")
agent = Agent(tools=[...], llm="gemini-2.0-flash")

# OpenAI
agent = Agent(tools=[...], llm="gpt-5)
agent = Agent(tools=[...], llm="gpt-4o")

# Anthropic
agent = Agent(tools=[...], llm="claude-4-5-haiku")
agent = Agent(tools=[...], llm="claude-4-6-sonnet")

Use light_llm + heavy_llm to split fast prefiltering from heavier code generation:

agent = Agent(
    tools=[...],
    light_llm="gemini-3.1-flash-lite-preview",   # fast, cheap — for tool selection
    heavy_llm="claude-4-6-sonnet",         # stronger — for code generation
)

Context manager

The agent cleans up automatically when used as a context manager:

with Agent(tools=[...], llm="gemini-3.1-flash-lite-preview") as agent:
    agent.run("Summarise last week's sales and email it to the team.")

For the full API reference and advanced guides see DOCS.md or delfhos.com/docs.

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

delfhos-0.6.0.tar.gz (283.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

delfhos-0.6.0-py3-none-any.whl (310.3 kB view details)

Uploaded Python 3

File details

Details for the file delfhos-0.6.0.tar.gz.

File metadata

  • Download URL: delfhos-0.6.0.tar.gz
  • Upload date:
  • Size: 283.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for delfhos-0.6.0.tar.gz
Algorithm Hash digest
SHA256 8d0bf45ffc7da3be8528a447f112918b5c15dc8eec8c45b7eb0b389259dbc348
MD5 98801a7b5ac61212747c7a12625abb28
BLAKE2b-256 552278662e34c71e111e604fe397e23dfd162d78fe5c90a6f2d3848bf104756d

See more details on using hashes here.

File details

Details for the file delfhos-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: delfhos-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 310.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for delfhos-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af6de04273ff24caaa685c8ad71413a1d53abe6213d8fbff9b6029368ea5c174
MD5 3520bb626387b6bb4700ecda57ef364c
BLAKE2b-256 bac899e21a243a1b43e99733bcbc01b4d84a22bda813706ba1529f5528566695

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page