Tool registry and execution runtime
The tool runtime makes workflow tools discoverable, configurable, and runnable as isolated container workloads. It connects tool metadata to a versioned image, starts that image through the runner, and returns tool status while streaming logs and execution updates to the platform. See the Connectors and tools page for the wider product view and Connector platform for the related adapter and service model.
Runtime model
Tool catalog
The tool registry is the catalog of tools that the platform can offer to workflows. A registry entry points to a local or container image and is paired with cached metadata that describes the tool name, function, version, settings schema, runtime variables, adapters, and icon. Public entries are shared across organizations. Private entries are available only to the running Unstract instance. The registry uses the tool function name as the stable tool identifier. References: unstract/…/README.md• L8-22, unstract/…/helper.py• L42-63, unstract/…/dto.py• L302-385
The registry can read metadata from a tool image and store it for later use. This separates workflow design from a live container lookup while keeping the image name and tag available for execution. A tool is usable only when its metadata includes both a settings description and a tool specification. References: unstract/…/helper.py• L75-191, unstract/…/tool_registry.py• L122-160, unstract/…/tool_registry.py• L214-282
Tool contract
Each tool exposes a small contract to the platform. The specification defines runtime settings. The properties define display and input/output behavior. Adapter declarations connect the tool to services such as language models and text extractors. Enabled adapter declarations become part of the settings schema used by the platform. References: unstract/…/dto.py• L38-141, unstract/…/dto.py• L214-299, unstract/…/tool_utils.py• L174-290
Tool sandbox
The tool sandbox is the execution boundary used by workflow code to inspect and run a registered image through the runner. It carries organization, workflow, execution, and file-run identity into the request. It also carries the tool instance settings and the environment that lets the container reach platform services. References: unstract/…/tool_sandbox.py• L8-34, unstract/…/tool_sandbox.py• L36-106, unstract/…/tools_utils.py• L97-154
The sandbox exposes two groups of runner operations. Metadata operations fetch the tool specification, properties, icon, and variables. Run operations start the image and return a result with a RUNNING, SUCCESS, or ERROR status. This gives callers one tool-facing boundary even when the runner uses different container back ends. References: unstract/…/constants.py• L1-16, unstract/…/dto.py• L6-39, unstract/…/helper.py• L637-675
Workflow execution
Workflow lifecycle
The workflow execution service moves a workflow through compile, build, and run stages. Compile creates the execution context. Build turns each configured tool instance into a sandbox. Run invokes the sandboxes in workflow order and checks that each tool produced the expected execution metadata before the workflow can finish. References: unstract/…/workflow_execution.py• L29-70, unstract/…/workflow_execution.py• L73-138, unstract/…/workflow_execution.py• L140-236
The tool loader is the link between a workflow definition and the registry. It confirms that every requested tool ID exists, checks that each instance has the data needed to run, and creates sandboxes with the selected image and instance settings. Missing tools, images, or instance properties stop the build rather than producing a partial workflow. References: unstract/…/tools_utils.py• L74-95, unstract/…/tools_utils.py• L97-163
Tool run state
The runner reports container state to the sandbox, while shared execution trackers record file and tool progress. The workflow layer treats a tool error or missing output as a failed step. Transient run errors can be retried, but a missing image is treated as a configuration problem and is not retried. References: unstract/…/tools_utils.py• L182-217, unstract/…/helper.py• L123-258, unstract/…/helper.py• L708-765
Executor dispatch
The workflow-execution package also provides the shared boundary for extraction work sent to executor workers. A dispatch can use the existing Celery path or the Postgres queue path. A feature flag selects the path per organization at dispatch time, and a failed flag check uses Celery as the safe default. Request-reply calls return a common success or failure result so callers do not need transport-specific branching. References: unstract/…/executor_rpc.py• L1-29, unstract/…/executor_rpc.py• L134-199, unstract/…/executor_rpc.py• L398-461
Execution environment
The runtime combines platform-defined values with tool access values before it starts a container. These values identify the platform service, text extraction service, Redis connection, execution mode, and optional asynchronous extraction limits. This shared environment lets bundled and custom tools use the same platform services without changing the workflow contract. References: unstract/…/tools_utils.py• L219-251, unstract/…/constants.py• L13-30
Tool-sidecar service
Sidecar monitoring
The tool-sidecar service runs beside a tool container and watches the shared log file. It converts structured tool log lines into platform log events, adds execution identity, and publishes those events for live monitoring. It also updates tool execution status so the runner can distinguish a completed tool from a container that only stopped. References: tool-sidecar/README.md• L1-13, tool-sidecar/…/log_processor.py• L39-76, tool-sidecar/…/log_processor.py• L112-166
Container coordination
When sidecar mode is enabled, the runner gives the tool and sidecar a shared volume for the log file and starts both containers as one execution unit. The sidecar waits for the log stream and watches for a result or termination signal. The runner polls the tracked container status and removes the tool and sidecar after completion or failure. References: runner/…/runner.py• L217-258, runner/…/runner.py• L297-329, runner/…/runner.py• L469-577, runner/…/docker_client.py• L218-327
Log and status contract
The sidecar accepts structured log types for normal logs, UI updates, cost data, results, and single-step events. An error log marks the tool as failed. A result marks it as successful. A termination marker ends monitoring even when the tool has no more log data. References: tool-sidecar/…/log_processor.py• L112-166, tool-sidecar/…/log_processor.py• L193-252, tool-sidecar/…/dto.py• L5-16
Bundled tools
File classifier
The file classifier assigns a document to a user-defined bin and copies the source file into that bin. It first obtains text through the selected text extraction adapter. It then asks the selected language model for one category and writes a JSON result that names the source and category. References: tools/…/main.py• L22-45, tools/…/main.py• L47-73, tools/…/main.py• L87-156, tools/…/properties.json• L2-18
The classifier requires at least two categories and reserves unknown for an unclear result and __unstract_failed for a failed file. It can use a configured text extractor or read text from the input file when no adapter is selected. The registry exposes it as the classify tool and binds it to the unstract/tool-classifier:0.0.80 image. Its image now uses a Python 3.12 slim base with the document parsing system packages needed by the bundled tool. References: tools/…/helper.py• L12-18, tools/…/helper.py• L30-52, tools/…/helper.py• L106-174, tools/classifier/Dockerfile#L1-L41, unstract/…/public_tools.json• L2-112
Text extractor
The bundled text extractor converts a document into text for downstream tool work. Its public tool contract requires a text extraction adapter and reports text as its result. The registry exposes it as text_extractor and binds it to the unstract/tool-text-extractor:0.0.76 image. Its image now uses a Python 3.12 slim base with the system packages needed for document parsing. References: tools/text_extractor/Dockerfile#L1-L42, unstract/…/public_tools.json• L113-197
Tool composition
The classifier and text extractor show how tools compose through adapter settings rather than direct tool-to-tool calls. The classifier selects an extractor for input text and an LLM for the category decision. The runtime supplies the service locations and execution identity that both tools need. References: tools/…/properties.json• L18-45, tools/…/main.py• L53-69, unstract/…/tools_utils.py• L229-250
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the registry image, tool UID, function name, version, and cached metadata aligned. A mismatch can hide a tool or start a different image than the one shown to users.
- Keep tool adapter declarations aligned with the settings keys consumed by the tool. The registry builds the platform schema from those declarations.
- Keep runner request fields aligned with the tool sandbox and sidecar environment. Execution IDs, file-run IDs, organization IDs, and the messaging channel must identify the same run across all containers.
- Keep sidecar log markers and tool log types aligned. A change can leave the tool running in the tracker or stop live updates without a clear error.
- Keep the executor result shape consistent across Celery and Postgres transports so workflow callers retain the same success and failure behavior.
- When changing a bundled tool's result bin, adapter contract, base image, or required system package, update its registry metadata and image build inputs as well as its runtime behavior.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Registry metadata has no usable specification or properties | The tool is omitted from the available tool set | Load and validate the tool metadata before building a workflow |
| A requested tool ID or container image is missing | Workflow build or tool run stops before useful work starts | Check registry membership and image availability before execution |
| Sidecar configuration lacks its image name or tag | Sidecar mode is disabled and the normal runner log path is used | Validate sidecar configuration before enabling the mode |
| Tool log output has no result or termination signal | The sidecar cannot mark the tool complete and polling can time out | Preserve the structured result and termination markers in tool output |
| Classifier input has fewer than two bins or lacks an LLM or extractor | The source is moved to the failed bin and the tool exits | Validate classifier settings before reading the document |
| A Postgres executor reply times out or is malformed | The caller receives a failed execution result even if the worker may still finish | Use a fresh reply key for a retry and inspect executor and reaper logs |
| A bundled tool image lacks a required document parsing package | The tool container starts but cannot process supported files | Keep the image system packages aligned with the tool's parsing needs |
Key files
| File | Why to read it |
|---|---|
| unstract/…/tool_registry.py | Main catalog interface for listing tools, reading metadata, and validating settings. |
| unstract/…/helper.py | Shows how registry entries become tool metadata and how public and private catalogs combine. |
| unstract/…/tool_sandbox.py | Shows the boundary between workflow execution and the runner. |
| unstract/…/workflow_execution.py | Shows the compile, build, and run lifecycle for workflow tools. |
| unstract/…/tools_utils.py | Shows tool loading, environment assembly, sandbox creation, retries, and image checks. |
| unstract/…/executor_rpc.py | Shows the common executor dispatch contract across queue transports. |
| runner/…/runner.py | Shows how the runner starts tool containers and coordinates optional sidecars. |
| tool-sidecar/…/log_processor.py | Shows how tool logs become live platform events and execution status. |
| tools/…/main.py | Shows the core bundled classification flow from extracted text to bin output. |
tools/classifier/Dockerfile | Shows the classifier image base and document parsing system dependencies. |
tools/text_extractor/Dockerfile | Shows the text extractor image base and document parsing system dependencies. |
| unstract/…/public_tools.json | Shows the public contracts and image versions for the bundled classifier and text extractor. |