> ## Documentation Index
> Fetch the complete documentation index at: https://docs.loom.teamecho.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Extension Points

> Customize and extend Loom for your use case.

Loom is designed to be adapted. Here are all the extension points available:

| Extension Point         | How                                                                        |
| ----------------------- | -------------------------------------------------------------------------- |
| Custom schema structure | Define your own paths in `UniversalSchemaDomain`                           |
| Custom schema templates | Create `.json` files in `./templates/` directory                           |
| Custom CM behavior      | Write your own `system_prompt_builder(state, registry) -> str`             |
| Custom chatbot prompt   | Pass any template with `{recalled_data}` placeholder                       |
| Custom tools            | Extend `SCProtocol.tools()` with domain-specific operations                |
| Custom persistence      | Replace `StateManager` / `SchemaFileManager` with your own backend         |
| Any LLM provider        | Set `base_url` to any OpenAI-compatible endpoint                           |
| Custom input formats    | Subclass `InputConverter` and implement `convert()`                        |
| Plugins                 | Register via `.use(plugin)` — add hooks & prompt vars without editing core |

## Custom Schema Structure

```python theme={null}
from loom import UniversalSchemaDomain

medical = UniversalSchemaDomain("medical_record")
medical.create_field("patient.name", "", "Patient full name")
medical.create_field("diagnosis.current", "", "Current diagnosis")
medical.create_field("medication.current", "", "Current medications")
medical.create_field("medication.allergies", "", "Drug allergies")

loom = Loom(config).register(medical)
```

## Custom CM Prompt

Override the CM agent's behavior by providing a custom `system_prompt_builder`:

```python theme={null}
def my_cm_prompt(state, registry):
    schema_overview = registry.inspect_all(max_depth=state.get("inspect_max_depth", 3))
    return f"""You are a medical records agent.

Available schemas:
{schema_overview}

Extract: diagnoses, medications, allergies, vitals.
When done: {{"continue": false}}"""

loom = Loom(config).cm_prompt(my_cm_prompt).chatbot_prompt(my_template)
```

## Custom Chatbot Prompt

The chatbot prompt template receives `{recalled_data}` (recalled schema content) and any custom variables injected by plugins:

```python theme={null}
my_template = """You are a helpful medical assistant.

Patient records:
{recalled_data}

{rag_section}

Respond based on the patient's records above."""
```

## Custom Input Formats

Subclass `InputConverter` for custom data formats:

```python theme={null}
from loom.converters import InputConverter

class MyConverter(InputConverter):
    def can_handle(self, data) -> bool:
        return isinstance(data, MyCustomType)

    def convert(self, data) -> str:
        return str(data)
```
