Skip to main content
Plexara
Integration12 min read

606 - Scripts as skills: the weekly review the agent runs on your business

The capstone. Three scripts (category velocity, the supplier quote margin review, regional weather context) attached to one prompt, so serving the prompt carries each script’s contract and last successful output and the agent runs them for fresh numbers instead of re-deriving them. The agent then reads the outputs against the seasonality calendar, the returns policy, the store formats, and the stock health bands, and produces the week’s action items: promote, discount, discontinue or renegotiate, watch, each with its figure. The scripts did the data work; the model did the judgment; neither is rebuilt next week.

What you will take away from this lesson

Every Monday somebody at ACME has to decide what to promote, what to discount, and what to stop carrying. The numbers behind that decision are the same every week: how each category sold against the week before, what the supplier’s latest quote does to margin, and whether a regional dip was weather. The judgment on top of the numbers is where the week’s work actually is.

This lesson builds that review on the demo tenant with everything the curriculum has covered: three managed scripts for the numbers, one prompt that carries them, five knowledge pages for the rules, and the agent for the judgment. The scripts run in seconds and are never rewritten. The review is a real asset with real figures.

Learning Objectives

  1. 01Compose several scripts into one job: a KPI extraction, a file join, and an API call.
  2. 02Attach scripts to a prompt through the agent, so serving the prompt carries each script’s contract and last successful output, never its source, and the agent runs them for fresh numbers instead of re-deriving them.
  3. 03Write the prompt so the agent reads the outputs against the knowledge graph and produces action items: promote, discount, discontinue or renegotiate, watch, each with its figure.
  4. 04Save the review as an asset, share it, and close the loop: feedback on the review becomes knowledge the next run reads.
  5. 05Understand that the scripts stay the owner’s while the review reaches the team; the shared output, not the code, is what everyone gets.
  6. 06Recognize the division of labor realized: the scripts did the data work, the model did the judgment, and neither is rebuilt next week.

Where this lesson sits

This is the last lesson of the 600 series and of the numbered curriculum. It uses the scripts from 602 through 604, the prompt mechanics from the 400 series, the registered table from the 500 series, and the knowledge loop from 206 and 307, and puts them to work on one recurring job.

600 Series: Automations

Open index

The 600 series picks up the registered table from the 500 series and the prompt mechanics from the 400 series. It is the last numbered series in the curriculum.

The job

A weekly merchandising review for ACME: what to promote, what to discount, what to discontinue or take back to the supplier, and what is moving for reasons nobody should act on. The numbers behind it come from three places, the warehouse, the supplier’s price sheet, and the weather archive, and each place has a script.

Three scripts, one each

  • acme-category-velocity

    last run 3,605 ms

    Computes
    Units and gross revenue per category for the review week against the week before, with each category’s tracked positions in the five stock health bands.
    Reaches
    Two warehouse queries.
    Outputs
    category-velocity (csv, 50 rows) and category-velocity-feed (json), assets 3fe22a6d-3868-4020-81ca-9a248b61736d and f39cf0f8-0456-4537-8e35-2241b9e6eb16.
  • acme-supplier-margin

    last run 8,231 ms

    Computes
    The current Blue Harbor quote against the cost of record and the shelf price, weighted by the month’s sales: cost change by category, the at-risk SKUs, and coverage. The 500 series’ registered table, read by a script.
    Reaches
    Three warehouse queries joined to the registered table.
    Outputs
    supplier-margin-by-category (csv), supplier-margin-feed (json), and the refreshed supplier-margin-dashboard, assets 871da875…, 589855b4…, and bab7c8e7….
  • acme-weather-context

    last run 1,856 ms

    Computes
    Each region’s revenue change for the week, paired with its anchor city’s highs, lows, precipitation, snowfall, and wet days from the historical weather archive.
    Reaches
    One warehouse query and eight calls through the open-meteo connection.
    Outputs
    weather-context (json, one entry per region) and weather-context-daily (csv, 56 rows), assets 2e10a16c-7f61-42dc-85f3-2f103349f99e and 047b038f-68ff-4fb3-919e-78387418c8c2.

The first two are the scripts from 602 and a sibling written the same way; the third is the one that reaches an outside API, eight archive calls through a connection Plexara already holds. All three run on the platform, under the roles their author held at the save (605).

The prompt

The prompt is the procedure. It tells the agent which scripts to run and with what, which knowledge pages to read before judging anything, what sections the review has, where to save it, whom to share it with, and to capture what it learned. It says nothing about how to compute a number, because the scripts own that.

The prompt, abridged to its structure

Produce the weekly merchandising review for the week starting {week_start}.

Do the data work with the attached scripts; do not re-derive their numbers yourself:
1. Run acme-category-velocity with week_start={week_start}
2. Run acme-supplier-margin with month set to the first day of the month and mode=refresh
3. Run acme-weather-context with week_start={week_start}

Read the outputs and apply the organization's knowledge before judging anything:
- ACME Retail Seasonality Calendar     - ACME Returns Policy
- ACME Store Formats                    - Inventory Stock Health
- Weather and Store Operations Playbook

Write the review as a markdown document:
- Headline   - Promote   - Discount   - Discontinue or renegotiate   - Watch
- Every item carries the figure that justifies it and names the script output it came from.

Save it with save_asset as "Weekly merchandising review, week of {week_start}", citing the
three run outputs. Share it with {recipient}, or create a link any signed-in user can open.
Finish by capturing, with memory_capture, any business fact the knowledge pages did not state.

Saved as the personal prompt weekly-merchandising-review, with week_start required and recipient optional. The prompt names the scripts and the knowledge pages and says what to do with each; it does not say how to compute anything, because the scripts already do. The 400 series covers how a prompt like this is authored, shared, and run (401 to 404).

Attaching the scripts

A prompt can reference the managed scripts its procedure depends on. Once attached, serving the prompt delivers each script’s contract and last successful output alongside the text, with the instruction to run the script for fresh numbers rather than re-derive them.

Attaching the three scripts

What the agent calls. This is the exchange the agent has with Plexara on your behalf, shown for the technical reader. You ask in plain language; you never type any of it.

manage_prompt command=attach_script name=weekly-merchandising-review
  script=mcp:script:cd8a42cc-c236-4607-9ff5-667029a9aa2c
→ status attached

manage_prompt command=attach_script name=weekly-merchandising-review
  script=mcp:script:f3dc47f5-81e6-4fcd-a344-40dd494f86e2
→ status attached

manage_prompt command=attach_script name=weekly-merchandising-review
  script=mcp:script:3ea98cce-00eb-4e55-9fcb-eb0fed9fc64a
→ status attached

Attaching is done through the agent; the portal’s prompt editor attaches reference material, not scripts. A script is its owner’s, so the reference resolves for the owner, and anyone else the prompt serves is told that part of its automation was unavailable rather than shown the script’s name or parameters. Deleting a referenced script does not break the prompt; it still serves and reports the reference as gone.

What the served prompt carries

When the agent resolves the prompt for a week, it receives the rendered instruction and, for each attached script, everything it needs to run it correctly: the parameter contract with types and defaults, the version that will execute, the schedule where one exists, and the outputs of the last successful run with their asset ids.

What the served prompt carries

What the agent calls. This is the exchange the agent has with Plexara on your behalf, shown for the technical reader. You ask in plain language; you never type any of it.

manage_prompt command=use name=weekly-merchandising-review args={"week_start":"2025-12-08"}
→ status resolved   content (rendered, with 2025-12-08 substituted)   scripts [3]
availability
embedded, for each of the three scripts, because the caller owns them.
contract
name, display name, the full description, owner, category, tags, status, enabled, and params with types and defaults: week_start (date, 2025-12-08), conn (connection, acme), and for the margin script mode (enum refresh or publish).
version
1, 6, and 1: the latest saved version of each, which is what run_script executes.
schedule
On the margin script only: cron_spec 0 7 * * 1, timezone America/Los_Angeles, next_run_at 2026-08-31T14:00:00Z.
last_successful_run
The run id, version, finished_at, and every output with its asset id and version, so the agent can read a recent result without running anything.
the instruction
“Call run_script with a script’s name and parameters to produce fresh output, and use what it returns rather than re-deriving the same result yourself.”

The contract never carries the source. Finding a script says it exists and what it takes; running it is still run_script under the run gate, and reading the code is still the owner’s to do.

The run

Say “run the weekly merchandising review for the week of December 8” and the agent does what the prompt says. The trace is short, and every number in the review comes from one of the first three calls.

The run, call by call

What the agent calls. This is the exchange the agent has with Plexara on your behalf, shown for the technical reader. You ask in plain language; you never type any of it.

  1. 1

    run_script name=acme-category-velocity args={"week_start":"2025-12-08"}

    succeeded in 3,605 ms · run dpx_953e18…· category-velocity v1, category-velocity-feed v1

  2. 2

    run_script name=acme-supplier-margin args={"month":"2025-12-01","mode":"refresh"}

    succeeded in 8,231 ms · run dpx_3bea16…· by-category v3, feed v3, dashboard v2 (refresh)

  3. 3

    run_script name=acme-weather-context args={"week_start":"2025-12-08"}

    succeeded in 1,856 ms · run dpx_837747…· weather-context v1, weather-context-daily v1

  4. 4

    fetch × 5: the seasonality calendar, the returns policy, the store formats, the stock health bands, the weather playbook

    five knowledge pages, read in full

  5. 5

    save_asset name="Weekly merchandising review, week of 2025-12-08" content_type=text/markdown references=[the three feed assets]

    asset 354ef652c40880981dbfa51787f12e60 · provenance captured, 3 calls recorded · references declared 3

  6. 6

    manage_asset action=share asset_id=354ef652… access_mode=authenticated

    a link any signed-in user can open · lasts until revoked · notified false

  7. 7

    memory_capture type=business_knowledge

    id 7bde39f329918d094e5d716a07b02eee · “Captured. It will be reviewed before promotion to a shared catalog.”

Three runs, five reads, one save, one share, one capture. The review declares the three feed assets as references, so its links to them resolve for everyone it is shared with. Nothing in the trace is a query the agent wrote; every number came from a script.

The review

The finished asset for the week of December 8 to 14, 2025, section by section. Each item carries the figure that justifies it, and the review names the feed each figure came from.

The review, week of 2025-12-08

  • Headline

    $4,688,138 against $4,500,609 the week before, up 4.1 percent.

    The normal second-week-of-December build toward the peak, not a demand event. Every region grew, from Southwest at +0.9 percent to Midwest at +6.4 percent.

  • Promote

    First Aid, Outdoor & Sports, Storage & Organization, Garden Supplies, Meat & Seafood.

    First Aid +12.6% to $96,232 with 3,981 of 5,757 positions Healthy and a projected margin of 31.7% under a quote up 3.9%; Outdoor & Sports +12.5% at 38.7%; Storage & Organization +11.4% at 38.9%; Garden Supplies +10.6% at 42.8%; Meat & Seafood +10.1% at 27.7%.

  • Discount

    Stationery, Pasta & Grains, Snacks & Chips, Paper Products, Pet Supplies.

    Stationery -5.2% to $109,474 at a 28.9% margin; Pasta & Grains -5.1% at 36.7%; Snacks & Chips -4.1% at 41.6%; Paper Products -4.0% at 34.4%; Pet Supplies -3.8% at 26.8%. All five hold about 70% of positions Healthy.

  • Discontinue or renegotiate

    SKU-000256, SKU-000175, SKU-000212, SKU-000313, SKU-000219.

    SKU-000256 Personal Care: price $61.92, cost of record $84.77, December quote $94.80, projected margin -53.1%, $792.37 a month. SKU-000175 -41.6%, $342.24. SKU-000212 -36.2%, $86.48. SKU-000313 -28.9%, $70.38. SKU-000219 +0.6% on a quote up 22.2%, $100.04. Twelve products carry a cost of record above their price, a catalog data-quality issue raised separately.

  • Watch

    Toys & Games, Gift Cards, Personal Care, Batteries & Electronics, Northwest, Southwest, Central, Midwest, the week of December 22.

    Toys & Games +10.6% and Gift Cards +3.0% are the December peak. Personal Care is up 7.0% in revenue but its quote is up 11.9% (margin 24.1 to 15.1). Batteries & Electronics +8.6% with a quote up 13.9%. Northwest +1.5% with five wet days in Seattle. Southwest +0.9% and Central +1.3% with dry weather deserve a store-level look. Midwest +6.4% through a cold snap.

Every figure traces to one of the three feeds, and the review names which. The asset is markdown, saved as 354ef652c40880981dbfa51787f12e60, with a link any signed-in user can open.

What the agent added that a script cannot

The scripts return fifty categories, twenty-five at-risk SKUs, and eight regions. The review is shorter than that because the agent held the outputs against the rules the knowledge pages state and left things out for stated reasons. Three of those reasons, quoted from the asset.

What the agent added, in its own words

  • Organic & Natural is the fastest category (+12.6 percent to $105,623) but is not on this list: its projected margin under the quote is 21.5 percent (down from 23.8) and 982 of its 5,757 positions are Critical Low or Out of Stock (17 percent). That is a replenishment problem first; promoting it would sell into empty shelves.
  • Baking Supplies is also down (-2.3 percent) but is excluded: the December quote raises its cost 14.5 percent and its projected margin falls to 31.3 percent from 40.0, so a markdown would stack on a cost increase. Hold price and see the Watch list.
  • Northwest grew only 1.5 percent; Seattle had five days with more than a tenth of an inch of rain that week. Per the weather playbook, that is weather, not performance. Southwest (+0.9 percent, Dallas dry, highs in the mid-60s) and Central (+1.3 percent, Denver dry) have no weather excuse and are worth a store-level look next week.

None of these sentences is in a script, and none could be. Each one holds two script outputs against a rule from a knowledge page: velocity against stock health, velocity against the supplier quote, a regional change against the weather playbook. That is the part of the week that needs a model, and it is the only part that gets one.

Getting smarter

The prompt’s last instruction is to capture any business fact the knowledge pages did not already state. The agent found one: a convention about what counts as gaining in the second week of December, and a rule about categories whose supplier quote moved by more than ten percent.

What the agent captured after the review

Weekly merchandising review convention: in December, week-over-week chain revenue growth of roughly 4 percent in the second week (the week of 2025-12-08 ran +4.1 percent, $4,688,138 against $4,500,609) is the normal build toward the peak, so a category has to beat that build to count as gaining. Categories whose December supplier quote (Blue Harbor) raised cost by more than 10 percent (Personal Care +11.9, Batteries & Electronics +13.9, Beer +13.4, Baking Supplies +14.5, Flowers & Plants +14.8) should not be promoted or discounted until the quote is renegotiated, whatever their velocity says. Stock health bands are nearly uniform across categories on the current snapshot (about 3.5 percent Out of Stock and 13 to 15 percent Critical Low everywhere), so a category’s band counts only mean something relative to that baseline.

Captured as business knowledge and placed in the review queue. Once it is promoted to a knowledge page, next Monday’s run reads it alongside the seasonality calendar, and the convention does not have to be rediscovered. Feedback on the review itself follows the same path: a thread on the asset (307) or on the prompt (403) becomes a correction the next run applies.

In the portal

The prompt has a page of its own, where it is read and its arguments checked before a run; the scripts have theirs, with the schedule, the run history, and the Failing tile that says whether Monday went well.

A prompt’s page in the portal, with its details, arguments, and content.
A prompt page in the portal, where the review prompt is read and its arguments checked. Script references are attached by the agent and served with the prompt; the page’s own attachment control is for reference material.

The scripts, on a Monday

The review’s three scripts sit on the Scripts page beside every other automation the owner keeps, each with its cadence and the outcome of its last run.

The Scripts page in the portal: each script with its schedule, next fire, and how its last run went, with Scripts, Scheduled, and Failing tiles above the list.
The three review scripts on the owner’s Scripts page, beside the rest. The Failing tile is the number most people open this page for; on a good Monday it reads zero.

The division of labor, realized

Lesson 601 opened the series with a rule: do not spend AI on what a script can do, do not write a script when the agent can write it, and spend the model on judgment about the data. This is what the rule looks like on a Monday morning.

The division of labor, realized

13.7 s
of platform time across the three runs: 3,605 + 8,231 + 1,856 ms
0
queries the agent wrote to produce the review
5
knowledge pages read before any judgment was made
Mondays 7:00
when the margin dashboard refreshes itself, Los Angeles time

The scripts did the data work; the model did the judgment; neither is rebuilt next week. The prompt runs again with a new week_start, the scripts run again with fresh data, and the review starts from the version that already works. That is the rule 601 opened the series with, carried through to a Monday morning.

The end of the series

Six lessons, three scripts, one prompt, one review. The agent wrote the code once, and from now on it reads the outputs and forms a view. The team gets the review; the owner keeps the scripts; the knowledge graph keeps what each week teaches.

Key terms

Five terms close the series and the numbered curriculum.

Key Terms

Referenced scriptattach_script
A managed script a prompt names, so serving the prompt carries the script’s contract and last successful output. Attached by the agent; resolves for the script’s owner.
Contract
What a served or fetched script reveals: name, description, typed parameters, whether a run would be admitted, its schedule, and its last successful run. Never the source.
Feed
A script output written as rows, under a stable name, that another document or an agent reads: here the JSON the review was built from.
Action item
A recommendation in the review (promote, discount, discontinue or renegotiate, watch) carrying the figure that justifies it and the script output it came from.
Division of labor
The rule the series runs on: a script for the deterministic part, the model for writing it and for judgment about its output, the knowledge graph for the rules the judgment applies.