What Is the Required Reading Order for an Agent Before Calling a Generation Tool in OpenMontage?

In OpenMontage, an agent must follow a strict five-step deterministic sequence—loading the global routing guide, agent catalog, agent-specific implementation, tool schema, and finally the tool itself—before invoking any generation tool.

OpenMontage enforces a deterministic agent-reading order to ensure that every generation request is properly routed, validated, and executed. This rigid sequence guarantees that configuration, schema definitions, and routing logic are fully loaded before the agent calls any video, 3-D, or asset generation tool. Skipping any stage in this pipeline risks undefined behavior, missing configuration, or schema mismatches.

The Five-Step Agent Reading Order in OpenMontage

The OpenMontage source code defines a mandatory ingestion sequence that every agent must complete. According to the repository structure in calesthio/OpenMontage, the required reading order is:

1. Global Routing Rules (AGENT_GUIDE.md)

The agent first consults AGENT_GUIDE.md at the repository root. This master guide defines which file to consult next and how the system routes requests between agents. It serves as the entry point for all agent decision-making.

  • Key file: AGENT_GUIDE.md
  • Purpose: Determines routing logic and initial request handling

2. Agent Catalogue (AGENTS.md)

Next, the agent reads AGENTS.md, the central registry that maps agent identities to their capabilities and permitted tools. This catalog ensures the agent knows which generation tools it is authorized to invoke.

  • Key file: AGENTS.md
  • Purpose: Registry of agents, capabilities, and available tools

3. Agent-Specific Module (e.g., backlot/server.py)

After identifying itself in the catalog, the agent loads its concrete implementation from a Python module such as backlot/server.py. This module handles preprocessing, validation, and state management before the tool is called.

  • Key file: backlot/server.py (example implementation)
  • Purpose: Concrete agent logic, validation, and state handling

4. Tool Schema Definition (schemas/tools/<tool>.schema.json)

Before constructing the payload, the agent must load the JSON schema from schemas/tools/<tool>.schema.json (e.g., schemas/tools/video_stitch.schema.json). This schema describes the exact input structure expected by the generation tool.

5. Tool Implementation (tools/<category>/<tool>.py)

Finally, the agent invokes the generation tool itself, located in tools/<category>/<tool>.py (e.g., tools/video/video_stitch.py). Only after successfully parsing the previous four stages does the agent execute this code to produce output.

How the Reading Order Is Enforced in Code

The OpenMontage codebase implements this sequence through explicit module imports and validation checks. A minimal Python example demonstrating the enforced order appears in the repository:


# 1️⃣ Load routing rules

from agent_guide import ROUTING_RULES   # AGENT_GUIDE.md → AGENT_GUIDE.py (generated)

# 2️⃣ Register agents

from agents import AGENT_REGISTRY       # AGENTS.md → agents.py (generated)

# 3️⃣ Initialise the specific agent

agent = AGENT_REGISTRY['backlot']       # backlot/server.py

# 4️⃣ Load and validate the tool’s schema

from jsonschema import validate
import json, pathlib

schema_path = pathlib.Path(__file__).parent / "schemas/tools/video_stitch.schema.json"
with open(schema_path) as f:
    schema = json.load(f)

def call_tool(payload: dict):
    # 4️⃣ Validate payload against schema

    validate(instance=payload, schema=schema)

    # 5️⃣ Invoke the generation tool

    from tools.video.video_stitch import stitch_video
    return stitch_video(**payload)

This flow mirrors the required reading order: routing rules → agent catalog → agent code → schema validation → tool execution. The agent cannot reach step 5 without successfully completing steps 1–4.

Why the Order Matters: Risks of Skipping Steps

The strict sequence prevents runtime failures. If an agent attempts to call stitch_video() from tools/video/video_stitch.py without first loading schemas/tools/video_stitch.schema.json, it risks passing malformed payloads that crash the generation pipeline. Similarly, bypassing AGENTS.md means the agent might attempt to invoke tools outside its permission scope, while ignoring AGENT_GUIDE.md results in incorrect request routing.

Summary

  • Step 1: Load AGENT_GUIDE.md for global routing rules.
  • Step 2: Consult AGENTS.md to verify agent capabilities and tool permissions.
  • Step 3: Initialize the agent-specific module (e.g., backlot/server.py).
  • Step 4: Validate inputs against schemas/tools/<tool>.schema.json.
  • Step 5: Execute the generation tool located in tools/<category>/<tool>.py.

Frequently Asked Questions

Can an agent skip AGENT_GUIDE.md if it already knows the route?

No. The OpenMontage architecture treats AGENT_GUIDE.md as the single source of truth for routing logic. Hardcoding routes violates the deterministic design and may cause inconsistencies when the guide is updated.

What happens if schema validation fails in step 4?

The agent raises a validation error before reaching the tool implementation in tools/<category>/<tool>.py. This prevents malformed inputs from reaching the generation pipeline, protecting downstream systems from crashes or corrupt output.

Is the reading order hardcoded or configurable?

The five-step sequence is hardcoded into the OpenMontage agent lifecycle. While individual file contents (schemas, agent logic) are configurable, the ingestion order itself is enforced by the framework to maintain system integrity.

How do I add a new generation tool to the reading order?

Create a new JSON schema in schemas/tools/<tool>.schema.json, implement the tool logic in tools/<category>/<tool>.py, and register the tool in AGENTS.md under the appropriate agent entry. The existing reading order automatically incorporates new tools following steps 1–5.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →