Tools
Reusable @tool capabilities agents can invoke.
Basic
Mathematical and date/time utilities:
Web
Web scraping and content extraction:
Help / documentation
Read the built Sphinx singlehtml manual (same source as the Help desktop app):
Read Agency Sphinx singlehtml help (TOC + semantic section search).
Database
Database query and schema tools:
- class agency.tools.database.DatabaseSchemaGenerator[source]
Bases:
objectAutomatically generates database schema for the chatbot.
- static get_field_info(field)[source]
Extract useful information from a model field.
- Parameters:
field – Django model field
- Returns:
Dictionary with field information
- Return type:
- static get_model_info(model)[source]
Extract complete information from a model.
- Parameters:
model – Django model class
- Returns:
Dictionary with model information
- Return type:
- class agency.tools.database.DatabaseReadTool(app_names=None, *, name='database_read', description='', args_schema=<class 'agency.tools.database.DatabaseReadTool.Arguments'>, return_direct=False, verbose=False, callbacks=None, tags=None, metadata=None, handle_tool_error=False, handle_validation_error=False, response_format='content', extras=None, db_schema=<factory>)[source]
Bases:
BaseToolTool to read data from the local database with auto-generated schema.
- class Arguments(*, model, user=None, query='', q_filter='', limit=10)[source]
Bases:
BaseModelInput parameters for DatabaseReadTool.
- Parameters:
- model_config = {}
- args_schema: Type[BaseModel]
Pydantic model class to validate and parse the tool’s input arguments.
Args schema should be either:
A subclass of pydantic.BaseModel.
A subclass of pydantic.v1.BaseModel if accessing v1 namespace in pydantic 2
- return_direct: bool
Whether to return the tool’s output directly.
Setting this to True means that after the tool is called, the AgentExecutor will
- get_model_class(model_name)[source]
Get model class by name.
- Parameters:
model_name (str) – Name of the model to retrieve
- Returns:
Django model class
- Raises:
ValueError – If model not found or cannot be loaded
- model_config = {'arbitrary_types_allowed': True, 'extra': 'ignore', 'protected_namespaces': ()}
- model_post_init(context, /)
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self (BaseModel) – The BaseModel instance.
context (Any) – The context.
Agent
Agent management tools:
Human
HITL interrupt tool:
HITL tool: pause a run and ask a human via LangGraph interrupt.
ask_human publishes a debug event and returns interrupt({...}) so the
run can be resumed after the human answers (see resume_mission / Interruption).
Python interpreter
Python code execution tools:
A tool for running python code in a REPL.
- class agency.tools.interpreter.PythonREPL(*, _globals=<factory>, _locals=<factory>)[source]
Bases:
BaseModelSimulates a standalone Python REPL.
- static sanitize_input(query)[source]
Sanitize input to the python REPL.
Remove whitespace, backtick & python (if llm mistakes python console as terminal)
- run(command, timeout=None)[source]
Run command with own globals/locals and returns anything printed.
- model_config = {}
- agency.tools.interpreter.sanitize_input(query)[source]
Sanitize input to the python REPL.
Remove whitespace, backtick & python (if llm mistakes python console as terminal)
- class agency.tools.interpreter.PythonREPLTool(*, name='Python_REPL', description='A Python shell. Use this to execute python commands. Input should be a valid python command. If you want to see the output of a value, you should print it out with `print(...)`.', args_schema=None, return_direct=False, verbose=False, callbacks=None, tags=None, metadata=None, handle_tool_error=False, handle_validation_error=False, response_format='content', extras=None, python_repl=<factory>, sanitize_input=True)[source]
Bases:
BaseToolTool for running python code in a REPL.
- python_repl: PythonREPL
- model_config = {'arbitrary_types_allowed': True, 'extra': 'ignore', 'protected_namespaces': ()}
- model_post_init(context, /)
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self (BaseModel) – The BaseModel instance.
context (Any) – The context.
- class agency.tools.interpreter.PythonInputs(*, query)[source]
Bases:
BaseModelPython inputs.
- model_config = {}
- class agency.tools.interpreter.PythonAstREPLTool(*, name='python_repl_ast', description='A Python shell. Use this to execute python commands. Input should be a valid python command. When using this tool, sometimes output is abbreviated - make sure it does not look abbreviated before using it in your answer.', args_schema=<class 'agency.tools.interpreter.PythonInputs'>, return_direct=False, verbose=False, callbacks=None, tags=None, metadata=None, handle_tool_error=False, handle_validation_error=False, response_format='content', extras=None, globals=<factory>, locals=<factory>, sanitize_input=True)[source]
Bases:
BaseToolTool for running python code in a REPL.
- args_schema: Type[BaseModel]
Pydantic model class to validate and parse the tool’s input arguments.
Args schema should be either:
A subclass of pydantic.BaseModel.
A subclass of pydantic.v1.BaseModel if accessing v1 namespace in pydantic 2
- classmethod validate_python_version(values)[source]
Validate that Python version is 3.9 or higher.
- Parameters:
values (Dict) – Model values to validate
- Returns:
Validated values
- Raises:
ValueError – If Python version is too old
- Return type:
- model_config = {'arbitrary_types_allowed': True, 'extra': 'ignore', 'protected_namespaces': ()}
- model_post_init(context, /)
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self (BaseModel) – The BaseModel instance.
context (Any) – The context.
Icons
Local ComfyUI (Compose comfy, SD 1.5) draws pixels on the GPU.
Ollama x/flux2-klein / x/z-image-turbo when the runtime supports
image gen; otherwise OpenAI Images or fal FLUX. The bitmap is keyed to a
128×128 white-on-transparent dock glyph. Optional tool_id is the catalog
id (tools.agent.create_agent) or a unique leaf (create_agent); a miss
still saves the PNG and lists closest rows. Each catalog leaf maps to a
concrete pictogram (clock, calculator) so SD 1.5 is not asked to draw Spanish
abstractions. The tool result echoes pictogram, SD prompt, negative and
checkpoint. list_catalog_tools (secretary) finds tools without an icon.
Generate Agency-style tool icons via an image model (not JSON geometry).
Ollama image models when the runtime supports them; otherwise OpenAI Images or fal FLUX. The bitmap is keyed to a 128×128 white-on-transparent dock glyph.
Pictures
generate_image is the color picture tool (256–1024, default 768).
Local ComfyUI first; pin model=fal-ai/flux-lora (or fal-ai/flux/schnell)
when FAL_KEY is set. Saves to Photos. Call show_media with the photo id
so the operator Media player shows it. Optional display assigns the
kiosk. Do not use the icon tool for maps or posters.
edit_image changes existing Photos rows (or whatever is on Media).
One picture: FAL FLUX /image-to-image first; ComfyUI LoadImage + denoise
if FAL is down. Default strength 0.35. Source aspect is kept (long side
≤ 1024). Two or more photo_ids: FLUX Kontext multi
(fal-ai/flux-pro/kontext/max/multi) with data-URI image_urls. Needs
FAL_KEY; no Comfy fallback. Result is a new generated photo on Media.
Generate and edit color pictures (ComfyUI / FAL FLUX).
Secretary
High-level operator tools bound to the secretary runtime (user_id,
agent_id, thread_id). They never take ambient admin. Desktop chrome
uses Agency Bus: open_window / close_window publish
desktop.<address>.visibility.changed; show_media publishes
desktop.media.now_playing.changed and opens the Media singleton. See
Veronica — built-in secretary.
High-level secretary tools for Veronica (context-bound, no ambient admin).
Display
Kiosk operator tools. An agent inspects screens/views/scopes, publishes a View,
assigns it to one named display, and mutates Scope properties (the live slide).
Never fan-out to every kiosk. Protected (padlock) screens and views refuse agent
writes. show_image_on_display is the presentation shortcut (Media image +
image_url) for a single named screen. Compose templates with
<agency-include namespace="display.example.clock">. Resolve by name,
slug, or namespace — never Channels group names.
High-level agency.display tools for agents (Veronica and specialists).
Do not send Channels group names. Resolve displays/views/scopes by id, slug, namespace, or unique name. Scope is the property bus — set_display_property changes the live slide.