Loom keeps your agents on track.

Tutorial 09: Promote repeated work into a rule

Continue from Tutorial 08. Load [loom_demo] from Loom for this session. [loom_demo] is writable for your account and includes starter data, so it is a good place to try promotion before you repeat the same pattern in your project store.

This example uses the public CSV bundled with the palmerpenguins tutorial repository and promotes a reusable species-and-island count. The promoted rule lives in the shared store rather than in one chat history, so it remains available after reconnecting to [loom_demo].

Public CSV used in this tutorial:

https://raw.githubusercontent.com/mcnakhaee/palmerpenguins/master/palmerpenguins/data/penguins.csv

The CSV has 344 rows and these relevant columns: species, island, body_mass_g, and year. The verified answer for Gentoo penguins on Biscoe island is 124 rows.

Start here: make loom_demo the session default

YouLoad the configured store named loom_demo and make it the default for this session only. Confirm the effective session default, and do not edit ~/.loom/stores.toml.
AgentThe agent connects to the existing loom_demo store and changes only this session's default routing.
Resultloom_demo is now the default for this session. Persistent configuration was not changed.

1. Run the calculation once

YouUsing the public penguins CSV, count how many Gentoo penguins are on Biscoe island. Do not save the CSV rows into Loom.
AgentThe agent reads the public CSV, checks the columns, filters rows where species is Gentoo and island is Biscoe, and returns the count.
ResultI read the public penguins CSV, found 344 rows, and counted 124 Gentoo penguins on Biscoe island. I did not save the CSV rows into Loom.

This is the boundary: Loom remembers the reusable method, not a private copy of the public data.

> Estimated LLM usage: Approximately 800 tokens for the first-pass work of locating the source, inspecting its shape, and constructing the filter. This is an external estimate, not a live per-turn measurement.

2. Promote the repeated count

A promoted rule turns repeated reasoning into shared, named behavior. The agent still chooses when the rule applies, but it no longer needs to rediscover the source, columns, and filter on every request.

YouWe ask species-and-island counts often. Promote or update the query in [loom_demo] as a deterministic rule calculation named count_penguins(species, island).
AgentThe agent first reads the current [loom_demo] rule catalog. It then creates or updates a named rule whose fwddata! fetches the public CSV, discovers the species and island columns, applies the requested filter, and returns the numeric count with source evidence. It preserves existing user files and does not store the CSV rows. If a previous run already promoted count_penguins, this pass updates or confirms the same rule in place — nothing fails or duplicates on a rerun.
Result[loom_demo] contains the executable count_penguins(species, island) rule. A live call for ("Gentoo", "Biscoe") read 344 rows and returned count 124 with the source URL, filter, and verification timestamp.

> Estimated LLM usage: Approximately 3,000 tokens to inspect the existing rule catalog, author or update the deterministic rule, preserve the surrounding user files, and verify the result. This is an external estimate, not a live per-turn measurement.

The promoted rule is useful because the repeatable part is deterministic: fetch the same public CSV, apply the requested two-column filter, and return one count.

3. Discover the rule in a fresh session

Start a new coding-harness session in the same repository. Make [loom_demo] the session default as shown above, but do not mention Loom, promotion, or the rule in the counting request:

YouCount how many Adelie penguins are on Torgersen island.
AgentThe fresh session reads the [loom_demo] rule catalog, recognizes that the request matches the promoted calculation, and calls count_penguins("Adelie", "Torgersen") in the store's user-rule namespace.
ResultThere are 52 Adelie penguins on Torgersen island. The promoted count_penguins("Adelie", "Torgersen") rule was called and returned the count with the source URL, exact filter, rows read, and UTC check time.

> Estimated LLM usage: Approximately 50 tokens to recognize the matching promoted rule, invoke it with the requested parameters, and report the result. This is an external estimate, not a live per-turn measurement.

The plain-language request is the verification: a new session can discover and call the stored rule without being told its name or reconstructing the calculation in the conversation. The rule still reads the public source at answer time, so if the CSV changes, the recomputed answer can change too.

This small example saves roughly 750 tokens on each repeated query compared with the estimated 800-token first pass. In real applications, the uncaptured workflow may require reading several files, discovering schemas, joining data, reconstructing filters, and checking domain-specific constraints. Repeating that reasoning can be very expensive, while a promoted deterministic rule keeps subsequent calls compact and consistent.

The agent also checks the active store's rule-source fingerprint on every user prompt. If that fingerprint changes during a session, the hook injects the refreshed rule catalog on that turn; when it is unchanged, the hook injects no duplicate catalog.

4. Verify the rule after reconnecting

Reconnecting proves that the rule lives in the shared store rather than in the current conversation or process. A different parameter pair also shows that it is reusable behavior, not a memorized answer.

YouMake my primary coding store the session default without editing stores.toml. Then unload [loom_demo], load it again without changing the session default, call the promoted rule with a different species and island, and finally make [loom_demo] the session default again.
AgentThe agent confirms the primary coding store is now the session default, unloads and reloads [loom_demo] while leaving that default unchanged, calls count_penguins("Chinstrap", "Dream"), then restores [loom_demo] as the session default.
ResultThe session default changed to the primary coding store; [loom_demo] unloaded and reloaded without taking over the default; the promoted rule read 344 rows and returned 68 Chinstrap penguins on Dream island; then [loom_demo] became the session default again. The rule persisted across the connection reset.

That is the payoff: promoted rules are shared store behavior. A connected agent does not need the original conversation to invoke the stored rule.

5. Verify the answer with evidence

Deterministic does not mean opaque. A useful promoted rule returns enough evidence to audit what it read and calculated, so agents can trust the method without repeating its construction.

YouShow me enough evidence that the promoted answer is not just a memorized number.
AgentThe agent calls the rule with another parameter pair and reports the source URL, row count, exact filter, result, and check time.
ResultSource: palmerpenguins/data/penguins.csv. Rows read: 344. Filter: species == Adelie and island == Torgersen. Count: 52. The live result includes a UTC checked_at timestamp, showing that the rule fetched and calculated the answer for these parameters.

Using a second parameter pair verifies that the rule is parameterized rather than a stored 124.

6. Move the pattern when it becomes project work

This tutorial keeps the write in [loom_demo]. When the same method becomes part of real project planning, repeat the promotion in your project store and ask the agent to verify the promoted answer there before relying on it.

7. Decide what to promote

Promote patterns like this when:

Do not promote one-time research, subjective choices, or fetched public data that should stay in the source system. Promote the repeatable method.

8. Takeaways