Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

autourgos-toolbox

Dynamic lazy-loading toolbox middleware for Autourgos agents.

Keeps the agent's context window clean by only showing toolbox names and descriptions upfront. The agent loads the tools it actually needs at runtime by calling expose_toolbox(name).


Why use this?

Real-world agents often need dozens of tools — GitHub, databases, web search, file system, APIs. Dumping all of them into the prompt at once:

  • Wastes tokens on tools the agent will never use for a given task
  • Confuses the LLM with too many choices
  • Can hit the context window limit before the task even starts

ToolboxMiddleware solves this by grouping tools into named toolboxes and only showing the catalog upfront. The agent picks what it needs and loads it on demand.


Install

pip install autourgos-toolbox

Depends on autourgos-agent. Works with any Autourgos agent.


Quick Start

from autourgos_toolbox import Toolbox, ToolboxMiddleware
from autourgos_agent import Agent

# Define toolboxes
web_box = Toolbox(
    name="web",
    description="Web search and page scraping tools.",
    tools=[web_search, scrape_url],
)
db_box = Toolbox(
    name="database",
    description="SQL query tools for the production database.",
    tools=[run_query, list_tables, describe_table],
)

# Attach middleware
middleware = ToolboxMiddleware(toolboxes=[web_box, db_box])
agent = Agent(llm=my_llm, middleware=[middleware])

result = agent.invoke("Find the latest Python release and log it to the database")
print(result)

When used with a verbose Agent (Agent(..., verbose=True)), this middleware narrates its own actions into the same trace as the agent's Thought/Action/Observation output, for example:

[Toolbox] Exposed toolbox 'web' to agent.

The agent sees this in its prompt at the start:

## Dynamic Toolboxes
Available Toolboxes:
- **web**: Web search and page scraping tools.
- **database**: SQL query tools for the production database.

When it needs the web tools, it calls:

{"action": "expose_toolbox", "action_input": {"toolbox_name": "web"}}

And immediately all web tools are registered and their schemas injected into the prompt.


How it works

  1. on_agent_start — middleware injects expose_toolbox and expose_tool meta-tools plus a toolbox catalog into the agent's system prompt. No actual tools are loaded yet.
  2. Agent calls expose_toolbox — all tools in that toolbox are registered on the agent and their schemas are appended to the prompt.
  3. Agent uses the tools — now fully loaded and callable.
  4. on_agent_end / on_agent_error — agent is fully restored to its original state (tools + prompt) so the next run starts clean.

Define toolboxes

As a list of Toolbox objects

from autourgos_toolbox import Toolbox, ToolboxMiddleware

github_box = Toolbox(
    name="github",
    description="Tools for reading and writing GitHub issues and PRs.",
    tools=[search_issues, create_pr, list_repos],
)

middleware = ToolboxMiddleware(toolboxes=[github_box])

As a dict

middleware = ToolboxMiddleware(toolboxes={
    "github": {
        "description": "Tools for reading and writing GitHub issues and PRs.",
        "tools": [search_issues, create_pr, list_repos],
    },
    "slack": {
        "description": "Tools for sending and reading Slack messages.",
        "tools": [send_message, read_channel],
    },
})

Add toolboxes dynamically

middleware = ToolboxMiddleware()
middleware.add_toolbox("github", "GitHub tools.", [search_issues, create_pr])
middleware.add_toolbox("slack", "Slack tools.", [send_message, read_channel])

Using StructuredTool

Tools can be plain callables or StructuredTool instances. StructuredTool auto-infers the JSON schema from type annotations and docstrings:

from autourgos_toolbox import StructuredTool

def search_issues(query: str, repo: str) -> str:
    """Search GitHub issues.

    Args:
        query: Search keywords.
        repo: Repository name in owner/repo format.
    """
    ...

tool = StructuredTool.from_function(search_issues)

Combine with other middleware

from autourgos_toolbox import ToolboxMiddleware, Toolbox
from autourgos_history import AgentHistoryMiddleware
from autourgos_summarizer import AutoSummarizeMiddleware

middleware = [
    ToolboxMiddleware(toolboxes=[web_box, db_box]),
    AutoSummarizeMiddleware(summarize_every=5),
    AgentHistoryMiddleware(),
]
agent = Agent(llm=my_llm, middleware=middleware)

Requirements

  • Python 3.9+
  • Any Autourgos agent with add_tools(), agent.tools, and agent.system_prompt / agent.prompt_template

License

MIT — see LICENSE

Metadata

Release files for autourgos-toolbox 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autourgos-toolbox 3.1.0
File Size Uploaded
autourgos_toolbox-3.1.0.tar.gz 12.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autourgos-toolbox 3.1.0
File Interpreter ABI Platform
autourgos_toolbox-3.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.5 kB

Release files / autourgos_toolbox-3.1.0.tar.gz

Download URL autourgos_toolbox-3.1.0.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f824253729144d569b98cb8e9553772a06e9f21fef89207fc81ed0e0d5bf8984
BLAKE2b-256 checksum
How to use checksums
65bae026ce7e01a030a7426b79c0da1615ad4a37093967c30a9461a88e8ad65c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / autourgos_toolbox-3.1.0-py3-none-any.whl

Download URL autourgos_toolbox-3.1.0-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be99a8188859094c9d7062fad9950d184910de09f80e24ee78d39a00bb73edb9
BLAKE2b-256 checksum
How to use checksums
7316d5b0b63e4f1151277310551d5054d0590909a4e7c4b2c41ec7121fb8729f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page