agentleFS
intersystems-communityintersystems-community/iris-agentic-dev/skills/pyprod/SKILL.md

pyprod

Skill41 starsChanged 3 months agoMITView on GitHub

Use when creating or modifying InterSystems IRIS interoperability production components in Python — Business Services, Business Processes, Business Operations, Adapters, Messages, or Production definitions.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Import from intersystems_pyprod — not grongier.pex or any other package.

    line 19
  2. Distinctive:

    Import only what your component needs — do not copy-paste the full import list into every file:

    line 21
  3. Very specific:

    Rule: Every async dispatch with response_required=1 must have a matching on_response in the same class.

    line 101
  4. Very specific:

    Every callback returns Status as its first element.

    line 163

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Building with pyprod

Read this skill once, then write all required files in one pass. Do not re-read between writes.

pyprod is the InterSystems Python library for IRIS interoperability productions. Import from intersystems_pyprod — not grongier.pex or any other package.

Import only what your component needs — do not copy-paste the full import list into every file:

ComponentTypical imports
MessageColumn, JsonSerialize (or PickleSerialize)
BusinessServiceIRISParameter, IRISProperty, BusinessService, IRISLog, Status
BusinessProcessIRISProperty, BusinessProcess, IRISLog, Status
BusinessOperationIRISParameter, IRISProperty, BusinessOperation, IRISLog, Status

Set the IRIS package name at module level (applies to all classes in the file):

iris_package_name = "MyPackage"

Messages

Messages passed between Business Hosts must subclass JsonSerialize or PickleSerialize. Use Column() for fields that should be SQL-queryable — a plain Python attribute is not persisted as a separate column.

class OrderMessage(JsonSerialize):
    order_id: str = Column(index=True)   # SQL column, indexed
    amount = Column(datatype=int)        # SQL column, integer
    note = "default"                     # NOT a Column — not SQL-queryable

Column(default=None, datatype=None, description=None, index=False) — string and numeric types only.


BusinessService

Receives input from an adapter (or direct call), packages it as a message, routes forward.

class MyService(BusinessService):

    ADAPTER = IRISParameter("MyPackage.MyAdapter")   # omit → adapterless (set pool_size=0)
    target = IRISProperty(
        settings="Target:selector?context={Ens.ContextSearch/ProductionItems?targets=1&productionName=@productionId}"
    )

    def on_process_input(self, input):
        request = OrderMessage(input)
        status, response = self.send_request_sync(self.target, request, timeout=-1)
        return status, response

send_request_async on BusinessService: (target, request, description="") — no response_required.


BusinessProcess

Orchestrates logic. New instance per message — no persistent state.

class MyProcess(BusinessProcess):

    target = IRISProperty(
        settings="Target:selector?context={Ens.ContextSearch/ProductionItems?targets=1&productionName=@productionId}"
    )

    def on_request(self, request):
        # response_required=1 (integer, not True) — MUST also implement on_response below
        status = self.send_request_async(self.target, request, response_required=1)
        return status, None

    # ⚠ REQUIRED — omitting on_response causes NotImplementedError at runtime
    def on_response(self, request, response, call_request, call_response, completion_key):
        return Status.OK(), response

Rule: Every async dispatch with response_required=1 must have a matching on_response in the same class. No exceptions. If you only want fire-and-forget, pass response_required=0 and omit on_response. Never use True/False — integer only.

For sync dispatch:

status, response = self.send_request_sync(self.target, request, timeout=-1)
return status, response

BusinessOperation

Receives typed requests, dispatches via MessageMap.

class MyOperation(BusinessOperation):

    ADAPTER = IRISParameter("MyPackage.MyAdapter")   # optional
    connection_url = IRISProperty(default="http://localhost", description="Target URL")

    MessageMap = {
        "MyPackage.OrderMessage": "handle_order",   # key = iris_package_name.ClassName
        "MyPackage.CancelMessage": "handle_cancel",
    }

    def handle_order(self, request):
        IRISLog.Info(f"Processing order to {self.connection_url}")
        return Status.OK(), None

    def handle_cancel(self, request):
        return Status.OK(), None

    def on_message(self, request):   # optional fallback for unmatched types
        return Status.OK()

send_request_async on BusinessOperation: (target, request, description="") — no response_required.


IRISProperty vs IRISParameter

IRISPropertyIRISParameter
PurposeOperator-configurable instance value (shows in production UI)Class-level constant
MutableYes, per-instanceNo
Use forURLs, targets, credentials, timeoutsAdapter class name (ADAPTER)
ADAPTER = IRISParameter("MyPackage.MyAdapter")   # constant — links adapter class
timeout = IRISProperty(default=30, description="Timeout in seconds")  # UI-editable

Status and Logging

Every callback returns Status as its first element. Use a tuple return in all message-handling methods:

return Status.OK(), response      # handler: success, pass response back
return Status.OK(), None          # handler: success, no response to pass back
return Status.ERROR("message"), None   # handler: failure

on_message (BusinessOperation fallback only) may return bare Status.OK().

IRISLog.Info("message")
IRISLog.Warning("message")
IRISLog.Error("message")

Common Mistakes

MistakeEffectFix
Plain attribute instead of Column()Field not SQL-queryableUse Column(datatype=...)
response_required=True (bool)Runtime errorUse integer 1
send_request_async(response_required=1) without on_responseNotImplementedError at runtimeAlways implement on_response alongside the async call
IRISParameter for UI-editable valueNot visible in production UIUse IRISProperty
IRISProperty on BusinessProcessState lost (new instance per message)Use only on adapters, services, operations
Wrong MessageMap key packageMessages not dispatchedKey must match iris_package_name of the message module
pool_size=1 for adapterless serviceHangsUse pool_size=0
Import from grongier.pexWrong libraryImport from intersystems_pyprod

Production Definition and Director

See [[pyprod-production-definition]] for the Production class and item types. See [[pyprod-director]] for start/stop/inject via Director.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.