@sassoftware/sas-score-mcp-serverjs 0.4.1-1 → 0.4.1-3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,123 +0,0 @@
1
- # Before / After Examples
2
-
3
- ## Example 1 — list-libraries (SAS Viya MCP)
4
-
5
- ### BEFORE (~620 tokens)
6
-
7
- ```
8
- ## list-libraries — enumerate CAS or SAS libraries
9
-
10
- LLM Invocation Guidance (critical)
11
- Use THIS tool when the user asks for: "list libs", "list libraries", "show cas libs", "show sas libs",
12
- "what libraries are available", "list caslib(s)", "enumerate libraries", "libraries in cas", "libraries in sas".
13
- DO NOT use this tool when the user asks for: tables inside a specific library (choose listTables),
14
- columns/metadata of a table, job/program execution, models, or scoring.
15
-
16
- Trigger Phrase → Parameter Mapping
17
- - "cas libs" / "in cas" / "cas libraries" → { server: 'cas' }
18
- - "sas libs" / "in sas" / "base sas libraries" → { server: 'sas' }
19
- - "all libs" / "all libs" -> {server: 'all'}
20
- → { server: 'all' }
21
- - "next" (after prior call) → { start: previous.start + previous.limit }
22
- - "first 20 cas libs" → { server: 'cas', limit: 20 }
23
- - If server unspecified: default to all.
24
-
25
- Parameters
26
- - server (cas|sas|all, default 'all')
27
- - limit (integer > 0, default 10)
28
- - start (1-based offset, default 1)
29
- - where (optional filter expression, default '')
30
-
31
- Response Contract
32
- Return JSON-like structure from helper; consumers may extract an array of library objects/names.
33
- If number of returned items === limit supply a pagination hint: start = start + limit.
34
-
35
- Behavior Summary
36
- - Pure listing; no side effects.
37
- - If ambiguous short request like "list" or "libs" and no prior context: assume { server: 'cas' }.
38
- - If user explicitly asks for ALL (e.g. "all cas libs") and count likely large, honor limit=50 unless
39
- user supplies a value; include note about paging.
40
-
41
- Disambiguation Rules
42
- - If user mentions a singular library name plus desire for tables ("list tables in SASHELP") choose
43
- listTables (not this tool).
44
- - If user mixes "tables" and "libraries" ask for clarification unless clearly about libraries.
45
-
46
- Examples
47
- - "list libraries" → { server: 'all', start:1, limit:10 }
48
- - "list libs" → { server: 'all', start:1, limit:10 }
49
- - "list sas libs" → { server: 'sas' }
50
- - "list cas libraries" → { server: 'cas' }
51
- - "show me 25 cas libraries" → { server:'cas', limit:25 }
52
- - "next" (after prior call {start:1,limit:10}) → { start:11, limit:10 }
53
- - "filter cas libs" (no criterion) → ask: "Provide a filter or continue without one?"
54
-
55
- Negative Examples (do not route here)
56
- - "list tables in public" (route to list-tables)
57
- - "list models, list tables, list jobs, list jobdef and similar request"
58
- - "describe library" (likely list-tables or table-info depending on follow-up)
59
- - "run program to make a lib" (run-sas-program tool)
60
-
61
- Error Handling
62
- - On backend error: return structured error with message field; do not hallucinate libraries.
63
- - Empty result set → return empty list plus (if start>1) a hint that paging may have exceeded available items.
64
-
65
- Rationale
66
- Concise, signal-rich description increases probability this spec is selected for generic library
67
- enumeration intents.
68
- ```
69
-
70
- ### AFTER (~210 tokens)
71
-
72
- ```
73
- list-libraries — enumerate CAS or SAS libraries.
74
-
75
- USE when: list/show/enumerate libraries, caslibs, sas libs, available libraries
76
- DO NOT USE for: listing tables in a library (→ list-tables), column/table metadata, job execution, models, scoring
77
-
78
- PARAMETERS
79
- - server: 'cas' | 'sas' | 'all' (default: 'all')
80
- - limit: integer > 0 (default: 10)
81
- - start: 1-based offset (default: 1)
82
- - where: optional filter expression (default: '')
83
-
84
- ROUTING RULES
85
- - "cas libs / cas libraries / in cas" → { server: 'cas' }
86
- - "sas libs / sas libraries / in sas" → { server: 'sas' }
87
- - "all libs / all libraries" → { server: 'all' }
88
- - "all cas libs" with no limit given → { server: 'cas', limit: 50 } + paging note
89
- - "next" after prior call (start:S, limit:L) → { start: S + L, limit: L }
90
- - "filter cas libs" with no filter given → ask: "What filter expression should I apply?"
91
- - server unspecified / ambiguous "list"/"libs" → { server: 'cas' }
92
-
93
- EXAMPLES
94
- - "list libraries" → { server: 'all', start: 1, limit: 10 }
95
- - "list cas libraries" → { server: 'cas', start: 1, limit: 10 }
96
- - "show me 25 sas libs" → { server: 'sas', limit: 25, start: 1 }
97
- - "next" (prev: start:1,limit:10) → { server: <same>, start: 11, limit: 10 }
98
-
99
- NEGATIVE EXAMPLES (do not route here)
100
- - "list tables in SASHELP" → list-tables
101
- - "list models / jobs / jobdefs" → respective tools
102
- - "run a program to create a lib" → run-sas-program
103
-
104
- PAGINATION
105
- If returned count === limit → hint: next start = start + limit.
106
- If start > 1 and result empty → note paging may exceed available items.
107
-
108
- ERRORS
109
- Return structured error with message field. Never hallucinate library names.
110
- ```
111
-
112
- **Token reduction: ~66%**
113
-
114
- ---
115
-
116
- ## Key patterns illustrated
117
-
118
- - Trigger phrases consolidated from 3 blocks → 1 ROUTING RULES block
119
- - "Rationale", "Behavior Summary", "Response Contract" sections eliminated
120
- - Orphaned `→ { server: 'all' }` arrow removed
121
- - Parameter defaults made explicit inline
122
- - Examples trimmed to one line each
123
- - Negative examples now name the redirect tool explicitly
@@ -1,91 +0,0 @@
1
- ---
2
- name: sas-read-and-score
3
- description: >
4
- Guide the full read → score workflow in SAS Viya: reading records from a table (using read-table
5
- or sas-query) and then scoring them with a MAS model (using model-score). Use this skill whenever
6
- the user wants to score records from a table, run a model against query results, predict outcomes
7
- for a set of rows, or any combination of fetching data and scoring it. Trigger phrases include:
8
- "score these records", "score results of my query", "run the model on this table",
9
- "predict for these customers", "fetch and score", "read and score", "score rows from",
10
- "run model on table data", or any request that combines reading table data with model prediction.
11
- ---
12
-
13
- # SAS Read → Score Workflow
14
-
15
- Orchestrates the full two-step pattern of reading records from a SAS/CAS table and scoring them
16
- with a deployed MAS model.
17
-
18
- This skill chains two sub-skills:
19
- 1. **sas-read-strategy** — Choose between `read-table` and `sas-query`
20
- 2. **sas-score-workflow** — Validate model, invoke scoring, present results
21
-
22
- ---
23
-
24
- ## Quick reference
25
-
26
- 1. **Does the user already have data in hand?**
27
- - Yes → skip to Step 2 (scoring)
28
- - No → use `sas-read-strategy` to fetch data
29
-
30
- 2. **Is the model name familiar?**
31
- - Yes → proceed to score
32
- - No → pause and use `find-model` / `model-info`
33
-
34
- 3. **Invoke model-score** with the fetched data
35
-
36
- 4. **Merge results** and present as a table
37
-
38
- ---
39
-
40
- ## Common flows
41
-
42
- **Flow A — Score rows from a table directly**
43
- > "Score the first 10 customers in Public.customers with the churn model"
44
-
45
- 1. Apply `sas-read-strategy` → use `read-table` to fetch 10 rows
46
- 2. Apply `sas-score-workflow` → invoke `model-score` and present results
47
-
48
- **Flow B — Score results of an analytical query**
49
- > "Score high-value customers (spend > 5000) in mylib.sales with the fraud model"
50
-
51
- 1. Apply `sas-read-strategy` → use `sas-query` for aggregation
52
- 2. Apply `sas-score-workflow` → invoke `model-score` and present results
53
-
54
- **Flow C — User supplies scenario data directly**
55
- > "Score age=45, income=60000, region=South with the churn model"
56
-
57
- 1. Skip read strategy
58
- 2. Apply `sas-score-workflow` → invoke `model-score` and present result
59
-
60
- **Flow D — Model unfamiliar**
61
- > "Score Public.applicants with the creditRisk2 model"
62
-
63
- 1. Model unfamiliar → use `find-model` to verify existence
64
- 2. Apply `sas-read-strategy` to fetch data
65
- 3. Apply `sas-score-workflow` to score
66
-
67
- ---
68
-
69
- ## For detailed guidance
70
-
71
- - **Read strategy decisions?** See `sas-read-strategy` skill
72
- - **Scoring validation and presentation?** See `sas-score-workflow` skill
73
-
74
- **Flow D — Model unfamiliar**
75
- > "Score Public.applicants with the creditRisk2 model"
76
-
77
- 1. Pause — "creditRisk2" is new
78
- 2. Suggest: `find-model` to confirm it exists, `model-info` to get input variables
79
- 3. Once confirmed → `read-table` + `model-score`
80
-
81
- ---
82
-
83
- ## Error handling
84
-
85
- | Problem | Action |
86
- |---|---|
87
- | Table not found | Ask for correct lib.tablename |
88
- | Model not found | Suggest find-model |
89
- | Field name mismatch | Show mismatch, ask user to confirm mapping |
90
- | Scoring error | Return structured error, suggest model-info |
91
- | Empty read result | Tell user, ask if they want to adjust the query/filter |
@@ -1,143 +0,0 @@
1
- ---
2
- name: sas-read-strategy
3
- description: >
4
- Guide the user in choosing the right data retrieval tool: read-table (for raw row access with filters)
5
- or sas-query (for analytical queries, aggregations, joins). Use this skill when the user wants to
6
- fetch records from a SAS/CAS table. Trigger phrases include: "read records from", "get data where",
7
- "fetch rows from", "query the table", "give me the first N records", "aggregate by", "join tables",
8
- or any request that starts with data retrieval.
9
- ---
10
-
11
- # SAS Read Strategy
12
-
13
- Guides the decision between `read-table` and `sas-query` based on the user's intent and the nature
14
- of the data operation.
15
-
16
- ---
17
-
18
- ## Determine the server location
19
-
20
- Before retrieving data, check which server(s) contain the table:
21
-
22
- 1. **Check both servers**: Use `find-table` to check if the table exists in CAS and/or SAS
23
- 2. **Decide server placement**:
24
- - If table exists **only in CAS** → set `server: "cas"`
25
- - If table exists **only in SAS** → set `server: "sas"`
26
- - If table exists **in both** → ask the user: *"The table exists in both CAS and SAS. Which server would you prefer to query from?"*
27
- - If table exists **in neither** → inform user and ask which library to search in
28
-
29
- ---
30
-
31
- ## Determine the read strategy
32
-
33
- Ask yourself: does the user already have the data in hand?
34
-
35
- - **Yes (user pasted values, or data is already in context)** → skip this strategy; data is ready to use.
36
- - **No** → choose the read tool based on intent:
37
-
38
- | User's Intent | Tool | Example |
39
- |---|---|---|
40
- | Get specific raw rows, apply simple filter, retrieve first N records | `read-table` | "Show me 10 rows from customers where status='active'" |
41
- | Aggregate/summarize, calculate, join tables, analytical question | `sas-query` | "Average salary by department", "Count orders by region" |
42
-
43
- ---
44
-
45
- ## Using read-table
46
-
47
- **When:**
48
- - User asks for raw records, row-by-row data
49
- - Simple WHERE filtering (e.g., "where status = 'active'")
50
- - Pagination needed ("first 50 rows", "next 10 rows")
51
-
52
- **How:**
53
- ```
54
- read-table({
55
- table: "tablename",
56
- lib: "libraryname",
57
- server: "cas" or "sas", // determined from find-table check
58
- limit: N, // default 10, adjust based on user request
59
- where: "..." // optional SQL WHERE clause
60
- })
61
- ```
62
-
63
- **Rules:**
64
- - Always determine the server first using `find-table`
65
- - Keep batch size ≤ 50 rows unless the user explicitly requests more
66
- - If table name is missing, ask: *"Which table should I read from? (format: lib.tablename)"*
67
- - If library is missing, ask: *"Which library contains the table?"*
68
- - If table exists in both servers, ask user which to use
69
- - Return raw column values; do not transform or aggregate
70
-
71
- ---
72
-
73
- ## Using sas-query
74
-
75
- **When:**
76
- - User asks for aggregation (SUM, AVG, COUNT, GROUP BY)
77
- - User asks for joins, calculations, or analytical insights
78
- - User's question is phrased analytically ("compare", "analyze", "breakdown", "trend")
79
-
80
- **How:**
81
- ```
82
- sas-query({
83
- table: "lib.tablename",
84
- query: "user's natural language question",
85
- sql: "SELECT ... FROM ... WHERE ... GROUP BY ..." // generated from query
86
- })
87
- ```
88
-
89
- **Rules:**
90
- - Check which server(s) contain the table using `find-table` first
91
- - If table exists in both CAS and SAS, ask user which to query from
92
- - Parse the user's natural language question into a PROC SQL SELECT statement
93
- - Ensure SELECT statement is valid SQL syntax
94
- - Do not add trailing semicolons to the SQL string
95
- - If table name is missing, ask: *"Which table should I query? (format: lib.tablename)"*
96
- - If the intent is unclear, ask for clarification: *"Do you want raw rows, or an aggregated summary?"*
97
-
98
- ---
99
-
100
- ## Common patterns
101
-
102
- **Pattern A — Raw row retrieval**
103
- > "Show me the first 5 rows from Public.customers"
104
-
105
- → `read-table({ table: "customers", lib: "Public", limit: 5 })`
106
-
107
- **Pattern B — Filtered retrieval**
108
- > "Get all high-value orders (amount > 5000) from mylib.orders"
109
-
110
- → `read-table({ table: "orders", lib: "mylib", where: "amount > 5000" })`
111
-
112
- **Pattern C — Aggregation**
113
- > "What is the average price by make in Public.cars?"
114
-
115
- → `sas-query({ table: "Public.cars", query: "average price by make", sql: "SELECT make, AVG(msrp) AS avg_price FROM Public.cars GROUP BY make" })`
116
-
117
- **Pattern D — Join + analysis**
118
- > "Show me total sales by customer in the sales and customers tables"
119
-
120
- → `sas-query()` with a JOIN in the generated SQL
121
-
122
- ---
123
-
124
- ## Error handling
125
-
126
- | Problem | Action |
127
- |---|---|
128
- | Table not found in either server | Ask: *"Which library contains the table? (e.g., Public, Samples, mylib)"* |
129
- | Table exists in both CAS and SAS | Ask: *"The table exists in both servers. Which would you prefer: CAS or SAS?"* |
130
- | Table exists only in one server | Use that server automatically in your request |
131
- | Library not found | Ask: *"Which library contains the table? (e.g., Public, Samples, mylib)"* |
132
- | Ambiguous intent (raw vs aggregate) | Ask: *"Do you want individual rows or a summary by some field?"* |
133
- | Empty result | Inform user, ask to adjust filter or query |
134
-
135
- ---
136
-
137
- ## Next steps
138
-
139
- Once data is retrieved, decide the next action based on context:
140
- - If user wants to **score** the data → move to `sas-score-workflow`
141
- - If user wants to **visualize** → present as table or chart
142
- - If user wants to **export** → format and offer download
143
- - If user wants to **analyze further** → ask clarifying questions
@@ -1,283 +0,0 @@
1
- ---
2
- name: sas-score-workflow
3
- description: >
4
- Guide the full model scoring workflow: validate model familiarity, route to appropriate scoring tool
5
- based on model type, invoke scoring with scenario data, and present merged results. Use this skill
6
- when the user wants to run predictions on data (already fetched or user-supplied). Supports generic
7
- syntax: "score with model <name>.<type> scenario =<params>" where type is job|jobdef|mas|scr|sas.
8
- Trigger phrases: "score these records", "predict using model", "run model on", "score with model X.mas".
9
- ---
10
-
11
- # SAS Score Workflow
12
-
13
- Orchestrates model validation, type-based routing, scoring invocation, and result presentation.
14
- Handles both MAS models and alternative scoring engines (jobs, jobdefs, SCR, SAS programs).
15
-
16
- ---
17
-
18
- ## Generic Scoring Syntax
19
-
20
- Users can invoke scoring with a unified syntax that automatically routes to the correct tool:
21
-
22
- ```
23
- score with model <name>.<type> [scenario =<key=value pairs>]
24
- score <name>.<type> [scenario =<key=value pairs>]
25
- ```
26
-
27
- **Type determines the routing:**
28
- - `.job` → route to `run-job` with scoring parameters
29
- - `.jobdef` → route to `run-jobdef` with scoring parameters
30
- - `.mas` → route to `model-score` (Model Analytical Service — default)
31
- - `.scr` → route to `scr-score` (SAS Container Runtime)
32
- - `.sas` → route to `run-sas-program` to run sas program in folder
33
-
34
- If no type is specified (bare model name), assume `.mas` (MAS model).
35
-
36
-
37
- ---
38
-
39
- ## Type-Based Routing
40
-
41
- Parse the model name to extract the type suffix and route accordingly:
42
-
43
- ### Type: `.mas` (Model Aggregation Service)
44
- - **Tool**: `model-score`
45
- - **Use for**: Standard MAS-deployed predictive models
46
- - **Example**: `score with model churn.mas scenario =age=45,income=60000`
47
- - **Invocation**: `model-score({ model: "churn", scenario: {...} })`
48
-
49
- ### Type: `.job` (SAS Viya Job)
50
- - **Tool**: `run-job`
51
- - **Use for**: Pre-built scoring jobs with parameters
52
- - **Example**: `score with model monthly_scorer.job scenario =month=10,year=2025`
53
- - **Invocation**: `run-job({ name: "monthly_scorer", scenario: {...} })`
54
-
55
- ### Type: `.jobdef` (SAS Viya Job Definition)
56
- - **Tool**: `run-jobdef`
57
- - **Use for**: Job definitions that perform scoring logic
58
- - **Example**: `score with model fraud_detector.jobdef using amount=500,merchant=online`
59
- - **Invocation**: `run-jobdef({ name: "fraud_detector", scenario: {...} })`
60
-
61
- ### Type: `.scr` (Score Code Runtime)
62
- - **Tool**: `scr-score`
63
- - **Use for**: Models deployed in SCR containers (REST endpoints)
64
- - **Example**: `score https://scr-host/models/loan.scr using age=45,credit=700`
65
- - **Invocation**: `scr-score({ url: "https://scr-host/models/loan", scenario: {...} })`
66
-
67
- ### Type: `.sas` (SAS Program / SQL)
68
- - **Tool**: `run-sas-program`
69
- - **Use for**: Custom SAS or SQL scoring code
70
- - **Example**: `score my_scoring_code.sas using x=1,y=2`
71
- - **Invocation**: `run-sas-program({ folder: "my_scoring_code", scenario: {...} })`
72
-
73
- ---
74
-
75
- ## Scenario Parsing
76
-
77
- The scenario parameter (comma-separated key=value pairs) is parsed into an object:
78
-
79
- ```
80
- scenario =age=45,income=60000,region=South
81
- ↓ parsed as:
82
- { age: "45", income: "60000", region: "South" }
83
- ```
84
-
85
- Accepted formats:
86
- - **String**: `age=45,income=60000`
87
- - **Object**: `{ age: 45, income: 60000 }`
88
- - **Array** (batch): `[ {age:45, income:60000}, {age:50, income:75000} ]`
89
-
90
- ---
91
-
92
- ## Step 1 — Check model familiarity before scoring
93
-
94
- Score immediately if:
95
- - The user names a specific model they've used before in this session, OR
96
- - The model name matches a previously confirmed model in the conversation
97
-
98
- Pause and suggest investigation if:
99
- - The model name is new, vague, or misspelled-looking (e.g. "the churn one", "that cancer model")
100
- - The user seems unsure of the required input variable names
101
-
102
- **Suggested message:**
103
- > "I don't recognize that model — want me to run `find-model` to confirm it exists,
104
- > or `model-info` to check its required inputs first?"
105
-
106
- ---
107
-
108
- ## Step 2 — Prepare the scenario data
109
-
110
- **For a single record** (one object):
111
- ```javascript
112
- scenario = { field1: value1, field2: value2, ... }
113
- ```
114
-
115
- **For batch scoring** (multiple records — the typical case):
116
- ```javascript
117
- scenario = [
118
- { field1: val1, field2: val2, ... },
119
- { field1: val3, field2: val4, ... },
120
- ...
121
- ]
122
- ```
123
-
124
- **Critical rules:**
125
- - Loop or call model-score **once per row**.
126
- - Field names in the scenario must match the model's expected input variable names **exactly**.
127
- - If table column names differ from model input names, **flag this to the user** and ask for confirmation before scoring.
128
- - Example: Table has `age_years`, but model expects `age` → ask user which column maps to which input.
129
- - Do not add units, labels, or extra metadata — raw field values only.
130
-
131
- ---
132
-
133
- ## Step 3 — Invoke the appropriate scoring tool
134
-
135
- Based on the type extracted from the model name, invoke the corresponding tool:
136
-
137
- **For `.mas` (default):**
138
- ```javascript
139
- model-score({
140
- model: "<modelname>",
141
- scenario: scenario, // object or array
142
- uflag: false // set true if you need field names prefixed with _
143
- })
144
- ```
145
-
146
- **For `.job`:**
147
- ```javascript
148
- run-job({
149
- name: "<jobname>",
150
- scenario: scenario
151
- })
152
- ```
153
-
154
- **For `.jobdef`:**
155
- ```javascript
156
- run-jobdef({
157
- name: "<jobdefname>",
158
- scenario: scenario
159
- })
160
- ```
161
-
162
- **For `.scr`:**
163
- ```javascript
164
- scr-score({
165
- url: "<scr_endpoint_url>",
166
- scenario: scenario
167
- })
168
- ```
169
-
170
- **For `.sas`:**
171
- ```javascript
172
- run-sas-program({
173
- src: "<sas_or_sql_code>",
174
- scenario: scenario
175
- })
176
- ```
177
-
178
- **Rules:**
179
- - Pass the full batch in one call; do not loop over rows
180
- - If scoring fails, return the structured error and suggest troubleshooting
181
- - For MAS models, include uflag parameter if underscore-prefixed output is needed
182
- - For jobs/jobdefs, scenario becomes parameter arguments
183
- - For SCR, include full URL endpoint
184
-
185
- ---
186
-
187
- ## Step 4 — Present the results
188
-
189
- Merge the scoring output back with the input records and present as a table where possible.
190
-
191
- **Always surface:**
192
- - The key prediction/score field(s) (e.g. `P_churn`, `score`, `prediction`, `P_risk`)
193
- - Any probability/confidence fields for classification models (e.g. `P_class0`, `P_class1`)
194
- - Selected input fields that drove the prediction, so the user can see context
195
-
196
- **Formatting:**
197
- - Present results in a table for clarity
198
- - If results exceed 10 rows, show the first 10 and ask: *"Want to see more results or export the full set?"*
199
- - Round numeric predictions to 2–4 decimal places for readability
200
-
201
- ---
202
-
203
- ## Common flows
204
-
205
- **Flow A — Score rows with MAS model**
206
- > "Score the first 10 customers in Public.customers with the churn model"
207
-
208
- 1. `read-table` → { table: "Public.customers", limit: 10 }
209
- 2. `model-score` → { model: "churn", scenario: [ ...10 row objects ] }
210
- 3. Present merged results with prediction + key inputs
211
-
212
- **Flow B — Score with a scoring job**
213
- > "Score December sales with the monthly_scorer job using month=12,year=2025"
214
-
215
- 1. `run-job` → { name: "monthly_scorer", scenario: { month: "12", year: "2025" } }
216
- 2. Capture job output and tables
217
- 3. Present results
218
-
219
- **Flow C — Score with a job definition**
220
- > "Run fraud detection jobdef on transaction amount=500, merchant=online"
221
-
222
- 1. `run-jobdef` → { name: "fraud_detection", scenario: { amount: "500", merchant: "online" } }
223
- 2. Capture log, listings, and tables
224
- 3. Present results
225
-
226
- **Flow D — Score with SCR endpoint**
227
- > "Score with the loan model at https://scr-host/models/loan using age=45, credit_score=700"
228
-
229
- 1. `scr-score` → { url: "https://scr-host/models/loan", scenario: { age: "45", credit_score: "700" } }
230
- 2. Capture prediction response
231
- 3. Present result
232
-
233
- **Flow E — Score results of an analytical query with MAS**
234
- > "Score high-value customers (spend > 5000) in mylib.sales with the fraud model"
235
-
236
- 1. `sas-query` → { table: "mylib.sales", sql: "SELECT * FROM mylib.sales WHERE spend > 5000" }
237
- 2. `model-score` → { model: "fraud", scenario: [ ...result rows ] }
238
- 3. Present merged results
239
-
240
- **Flow F — User supplies scenario data directly**
241
- > "Score age=45, income=60000, region=South with the churn model"
242
-
243
- 1. Skip read step
244
- 2. `model-score` → { model: "churn", scenario: { age: "45", income: "60000", region: "South" } }
245
- 3. Present result
246
-
247
- **Flow G — Model unfamiliar, need to confirm**
248
- > "Score Public.applicants with the creditRisk2 model"
249
-
250
- 1. Pause — "creditRisk2" is new
251
- 2. Suggest: `find-model` to confirm it exists, `model-info` to get input variables
252
- 3. Once confirmed → `read-table` + `model-score`
253
-
254
- **Flow H — Generic score syntax with type routing**
255
- > "score with model churn.mas scenario =age=45,income=60000"
256
- > "score fraud_detector.jobdef where scenario =amount=500"
257
- > "score monthly_report.job using month=10,year=2025"
258
-
259
- 1. Parse model name to extract type (.mas, .job, .jobdef, .scr, .sas)
260
- 2. Route to appropriate tool based on type
261
- 3. Parse scenario and invoke tool with parameters
262
- 4. Present results from routed tool
263
-
264
- ---
265
-
266
- ## Error handling
267
-
268
- | Problem | Action |
269
- |---|---|
270
- | Model not found | Suggest `find-model` to verify the model is deployed |
271
- | Input field name mismatch | Show the mismatch (table has X, model expects Y), ask user to confirm mapping |
272
- | Scoring error / invalid inputs | Return structured error, suggest `model-info` to check required inputs and data types |
273
- | Empty read result | Tell user, ask if they want to adjust the query/filter before scoring |
274
- | Missing input fields | Ask which table columns map to the required model inputs |
275
-
276
- ---
277
-
278
- ## Tips
279
-
280
- - **Batch is better:** Always pass the full set of records in one `model-score` call. Do not loop.
281
- - **Confirm mappings:** If column names don't match model inputs, ask before scoring.
282
- - **Show context:** Include key input columns in the result output so predictions make sense.
283
- - **Limit output:** For large result sets (>10 rows), ask before showing all.