Skip to content

Commit 1b75a54

Browse files
akoclaude
andcommitted
docs: align CREATE AGENT syntax with CREATE REST CLIENT
Reshapes the CREATE AGENT syntax to match the established REST CLIENT pattern: top-level (Key: Value) config plus a {...} body with singular TOOL, KNOWLEDGE BASE, and MCP SERVICE blocks, each with their own (Key: Value) properties. Changes: - Moved Variables into inline config property (matches REST CLIENT's Parameters: ($id: String) style) - Replaced TOOLS (...) / KNOWLEDGE BASES (...) / MCP SERVICES (...) separate clauses with TOOL / KNOWLEDGE BASE / MCP SERVICE blocks inside a {...} body - Tool/KB/MCP properties (Microflow, Description, Access, Collection, MaxResults, MinSimilarity) use the regular Key: Value form instead of positional keywords - Body is omitted when there are no tools/KB/MCP - ALTER AGENT revised to use SET/INSERT/DROP operations inside a {...} body, matching ALTER PAGE - Updated all seven examples and the DESCRIBE AGENT sample output Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bd13cae commit 1b75a54

1 file changed

Lines changed: 128 additions & 97 deletions

File tree

docs/11-proposals/PROPOSAL_agent_document_support.md

Lines changed: 128 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -105,61 +105,66 @@ Output (round-trippable MDL):
105105
CREATE AGENT AgentEditorCommons."TranslationAgent" (
106106
UsageType: Task,
107107
Entity: System.Language,
108+
Variables: ("Description": EntityAttribute),
108109
SystemPrompt: 'Translate the given text into {{Description}}.',
109110
UserPrompt: 'What is a multi-agent AI system?...'
110-
)
111-
VARIABLES (
112-
"Description" ENTITY ATTRIBUTE
113111
);
114112
/
115113
```
116114

117115
### CREATE AGENT
118116

119-
Simple task agent:
117+
The syntax follows the same shape as `CREATE REST CLIENT`: top-level configuration in `(...)` followed by a `{...}` body containing one block per attached resource (`TOOL`, `KNOWLEDGE BASE`, `MCP SERVICE`). Simple agents with no resources omit the body entirely.
118+
119+
**Simple task agent (no body needed):**
120120

121121
```sql
122122
CREATE AGENT MyModule."SentimentAnalyzer" (
123123
UsageType: Task,
124124
Entity: MyModule.FeedbackItem,
125+
Variables: ("FeedbackText": EntityAttribute),
125126
SystemPrompt: 'Analyze the sentiment of {{FeedbackText}}. Classify as positive, negative, or neutral.',
126127
UserPrompt: '{{FeedbackText}}'
127-
)
128-
VARIABLES (
129-
"FeedbackText" ENTITY ATTRIBUTE
130128
);
131129
```
132130

133-
Agent with tools, knowledge bases, and MCP services:
131+
**Agent with tools, knowledge bases, and MCP services:**
134132

135133
```sql
136134
CREATE AGENT MyModule."ResearchAssistant" (
137135
UsageType: Conversational,
138136
Description: 'Research assistant with tools and knowledge base',
139-
SystemPrompt: 'You are a research assistant.',
137+
Variables: ("Topic": String),
138+
SystemPrompt: 'You are a research assistant helping research {{Topic}}.',
140139
UserPrompt: 'What are the latest trends in renewable energy?'
141140
)
142-
TOOLS (
143-
"GetCurrentTime" MICROFLOW MyModule.Tool_GetCurrentTime
144-
DESCRIPTION 'Get the current date and time'
145-
ACCESS VisibleForUser,
146-
"SendEmail" MICROFLOW MyModule.Tool_SendEmail
147-
DESCRIPTION 'Send an email notification'
148-
ACCESS UserConfirmationRequired
149-
)
150-
KNOWLEDGE BASES (
151-
MyModule.ResearchKB
152-
COLLECTION 'research-papers'
153-
MAX_RESULTS 10
154-
MIN_SIMILARITY 0.75
155-
)
156-
MCP SERVICES (
157-
MyModule.WebSearchMCP ACCESS VisibleForUser,
158-
MyModule.FileSystemMCP ACCESS UserConfirmationRequired
159-
)
160-
VARIABLES (
161-
"Topic"
162-
);
141+
{
142+
TOOL GetCurrentTime {
143+
Microflow: MyModule.Tool_GetCurrentTime,
144+
Description: 'Get the current date and time',
145+
Access: VisibleForUser
146+
}
147+
148+
TOOL SendEmail {
149+
Microflow: MyModule.Tool_SendEmail,
150+
Description: 'Send an email notification',
151+
Access: UserConfirmationRequired
152+
}
153+
154+
KNOWLEDGE BASE MyModule.ResearchKB {
155+
Collection: 'research-papers',
156+
MaxResults: 10,
157+
MinSimilarity: 0.75
158+
}
159+
160+
MCP SERVICE MyModule.WebSearchMCP {
161+
Access: VisibleForUser
162+
}
163+
164+
MCP SERVICE MyModule.FileSystemMCP {
165+
Access: UserConfirmationRequired
166+
}
167+
};
163168
```
164169

165170
### DROP AGENT
@@ -173,13 +178,14 @@ DROP AGENT MyModule."SentimentAnalyzer"
173178
| Decision | Rationale |
174179
|----------|-----------|
175180
| `AGENT` as document type keyword | Matches `Metadata.ReadableTypeName = "Agent"` and Mendix UI terminology |
176-
| `UsageType: Task` in properties | Follows standard `(Key: value)` property pattern used by all MDL commands |
177-
| `VARIABLES`, `TOOLS`, `KNOWLEDGE BASES`, `MCP SERVICES` as separate clauses | Each is structurally distinct; clauses keep the property block readable and mirror the Agent Editor UI's tabbed sections |
178-
| `ENTITY ATTRIBUTE` modifier on variables | Distinguishes entity-bound variables (auto-replaced from context object attributes) from free-form template variables |
179-
| `ACCESS` modifier on tools/MCP | Maps to `GenAICommons.ENUM_UserAccessApproval` (`HiddenForUser` / `VisibleForUser` / `UserConfirmationRequired`) |
180-
| Tools reference microflows by qualified name | Matches the Agent Editor behavior: the microflow signature becomes the tool JSON schema |
181-
| Knowledge bases reference KB documents (future Phase 4 addition) | KB documents are a separate `CustomBlobDocument` type that also needs MDL support |
182-
| MCP services reference ConsumedMCPService documents (Phase 4) | Same pattern as KB — a separate document type for MCP server configs |
181+
| Top-level `(Key: Value)` config + `{...}` body with singular blocks | Mirrors `CREATE REST CLIENT ... (...) { OPERATION Name {...} }` exactly — same shape, same mental model |
182+
| `TOOL`, `KNOWLEDGE BASE`, `MCP SERVICE` as singular block types | Matches the `OPERATION` singular used in REST CLIENT; each block defines one resource |
183+
| `TOOL <Name> { Microflow: ..., Description: ..., Access: ... }` | `Microflow`, `Description`, `Access` are regular properties (not positional), same as REST CLIENT operation properties |
184+
| `KNOWLEDGE BASE <QualifiedName>` (module-qualified) | The name references an external KB document (peer `CustomBlobDocument`), not a free-form identifier |
185+
| `MCP SERVICE <QualifiedName>` (module-qualified) | Same rationale — references a ConsumedMCPService document |
186+
| `Variables: ("Name": EntityAttribute, ...)` inline | Variables are 1–2 properties each; inline matches how REST CLIENT handles `Parameters: ($id: String)` and `Headers: ('Accept' = 'application/json')` |
187+
| `Access: VisibleForUser` as enum literal | Maps to `GenAICommons.ENUM_UserAccessApproval` values: `HiddenForUser`, `VisibleForUser`, `UserConfirmationRequired` |
188+
| Body omitted when there are no tools/KB/MCP | Same concession REST CLIENT makes implicitly — empty bodies are awkward; drop them |
183189
| Prompts as string literals | Consistent with other MDL string properties; `{{var}}` placeholders are just text |
184190

185191
> **Note on tool storage:** In the 4 observed agents in the test3 project, the `tools`, `knowledgebaseTools`, and MCP arrays in the `Contents` JSON are empty — all the sample agents are simple `Task` agents without tools. According to the [Agent Editor documentation](https://docs.mendix.com/appstore/modules/genai/genai-for-mx/agent-editor/), tools and knowledge bases ARE configured on the agent in the editor (not at runtime), so the `Contents` JSON schema supports them. Implementation will need to verify the exact JSON shape with an agent that has tools attached — a known gap flagged in the Open Questions section.
@@ -295,7 +301,7 @@ In `sdk/mpr/writer_agent.go`:
295301
#### 2.3 Validation
296302

297303
- Entity reference must exist (if specified)
298-
- Variables marked `ENTITY ATTRIBUTE` must correspond to attributes on the referenced entity
304+
- Variables marked `EntityAttribute` must correspond to attributes on the referenced entity
299305
- `UsageType` must be a known value (`Task` or `Conversational`)
300306
- Variable names used in `{{...}}` in prompts should match declared variables (warning, not error)
301307
@@ -316,7 +322,7 @@ In `sdk/mpr/writer_agent.go`:
316322
agents:
317323
agent_document:
318324
min_version: "11.9.0"
319-
mdl: "CREATE AGENT Module.Name (...) VARIABLES (...)"
325+
mdl: "CREATE AGENT Module.Name (...) { TOOL ... { ... } ... }"
320326
notes: "Requires AgentEditorCommons marketplace module"
321327
```
322328
- Executor pre-check: `checkFeature("agent_document")` before CREATE
@@ -355,7 +361,7 @@ CREATE KNOWLEDGE BASE MyModule."ProductDocsKB" (
355361
);
356362
```
357363

358-
Referenced from agents via the `KNOWLEDGE BASES (...)` clause.
364+
Referenced from agents via `KNOWLEDGE BASE <QualifiedName> { ... }` blocks inside the agent body.
359365

360366
#### 4.3 `CREATE CONSUMED MCP SERVICE` Document
361367

@@ -368,7 +374,7 @@ CREATE CONSUMED MCP SERVICE MyModule."WebSearchMCP" (
368374
);
369375
```
370376

371-
Referenced from agents via the `MCP SERVICES (...)` clause.
377+
Referenced from agents via `MCP SERVICE <QualifiedName> { ... }` blocks inside the agent body.
372378

373379
#### 4.4 `CALL AGENT` / `NEW CHAT FOR AGENT` Microflow Activities
374380

@@ -384,14 +390,21 @@ These need a new BSON activity type (or mapping to the generic Java action call
384390

385391
#### 4.5 ALTER AGENT
386392

393+
Follows the same shape as `ALTER PAGE` — in-place modifications to top-level properties and body blocks:
394+
387395
```sql
388-
ALTER AGENT MyModule."SentimentAnalyzer"
389-
SET SystemPrompt = 'New prompt with {{Variable}}.',
390-
ADD VARIABLE "NewVar" ENTITY ATTRIBUTE,
391-
ADD TOOL "NewTool" MICROFLOW MyModule.NewToolMicroflow
392-
DESCRIPTION 'A new tool' ACCESS VisibleForUser,
393-
DROP TOOL "OldTool",
394-
DROP VARIABLE "OldVar";
396+
ALTER AGENT MyModule."SentimentAnalyzer" {
397+
SET SystemPrompt = 'New prompt with {{Variable}}.';
398+
SET Variables = ("FeedbackText": EntityAttribute, "NewVar": String);
399+
400+
INSERT TOOL NewTool {
401+
Microflow: MyModule.NewToolMicroflow,
402+
Description: 'A new tool',
403+
Access: VisibleForUser
404+
};
405+
406+
DROP TOOL OldTool;
407+
};
395408
```
396409

397410
## Building Smart Apps with MDL: End-to-End Examples
@@ -642,20 +655,28 @@ Guidelines:
642655
- If you cannot resolve an issue, create a support ticket
643656
- Be empathetic and professional in your responses'
644657
)
645-
TOOLS (
646-
"LookupCustomer" MICROFLOW Support.Tool_LookupCustomer
647-
DESCRIPTION 'Look up a customer by their email address'
648-
ACCESS VisibleForUser,
649-
"GetOrders" MICROFLOW Support.Tool_GetOrders
650-
DESCRIPTION 'Get recent orders for a customer by name'
651-
ACCESS VisibleForUser,
652-
"CreateTicket" MICROFLOW Support.Tool_CreateTicket
653-
DESCRIPTION 'Create a new support ticket with the given subject, description, and priority'
654-
ACCESS UserConfirmationRequired
655-
);
658+
{
659+
TOOL LookupCustomer {
660+
Microflow: Support.Tool_LookupCustomer,
661+
Description: 'Look up a customer by their email address',
662+
Access: VisibleForUser
663+
}
664+
665+
TOOL GetOrders {
666+
Microflow: Support.Tool_GetOrders,
667+
Description: 'Get recent orders for a customer by name',
668+
Access: VisibleForUser
669+
}
670+
671+
TOOL CreateTicket {
672+
Microflow: Support.Tool_CreateTicket,
673+
Description: 'Create a new support ticket with the given subject, description, and priority',
674+
Access: UserConfirmationRequired
675+
}
676+
};
656677
```
657678

658-
The `ACCESS` modifier maps to `GenAICommons.ENUM_UserAccessApproval`:
679+
The `Access` property maps to `GenAICommons.ENUM_UserAccessApproval`:
659680
- `HiddenForUser` — tool executes silently
660681
- `VisibleForUser` — tool call is shown in the chat UI but executes automatically
661682
- `UserConfirmationRequired` — tool call is shown and user must approve before execution
@@ -855,6 +876,7 @@ CREATE AGENT Research."ResearchAssistant" (
855876
UsageType: Conversational,
856877
Description: 'Research assistant with web search and document analysis via MCP',
857878
Entity: Research.ResearchProject,
879+
Variables: ("Title": EntityAttribute, "Objective": EntityAttribute),
858880
SystemPrompt: 'You are a research assistant helping with project: {{Title}}.
859881
860882
Objective: {{Objective}}
@@ -866,13 +888,11 @@ Use the available tools to:
866888
867889
Always cite your sources. Present findings in a structured format.'
868890
)
869-
VARIABLES (
870-
"Title" ENTITY ATTRIBUTE,
871-
"Objective" ENTITY ATTRIBUTE
872-
)
873-
MCP SERVICES (
874-
Research.ResearchTools ACCESS VisibleForUser
875-
);
891+
{
892+
MCP SERVICE Research.ResearchTools {
893+
Access: VisibleForUser
894+
}
895+
};
876896
```
877897

878898
#### Step 5: Action Microflow — Same Simple Pattern
@@ -951,6 +971,7 @@ CREATE AGENT Reviews."SentimentAnalyzer" (
951971
UsageType: Task,
952972
Description: 'Single-call agent that extracts sentiment and themes from a product review',
953973
Entity: Reviews.ProductReview,
974+
Variables: ("ProductName": EntityAttribute, "ReviewText": EntityAttribute),
954975
SystemPrompt: 'Analyze the following product review for {{ProductName}}.
955976
956977
Extract:
@@ -961,10 +982,6 @@ Respond in this exact format:
961982
Sentiment: <sentiment>
962983
Themes: <theme1>, <theme2>, <theme3>',
963984
UserPrompt: '{{ReviewText}}'
964-
)
965-
VARIABLES (
966-
"ProductName" ENTITY ATTRIBUTE,
967-
"ReviewText" ENTITY ATTRIBUTE
968985
);
969986
```
970987

@@ -1107,14 +1124,19 @@ You have access to tools that can:
11071124
IMPORTANT: Always show the expense details before recommending approval.
11081125
Never approve expenses that exceed typical department limits without explicit user instruction.'
11091126
)
1110-
TOOLS (
1111-
"LookupExpenses" MICROFLOW Finance.Tool_LookupExpenses
1112-
DESCRIPTION 'List pending expense reports for a department'
1113-
ACCESS VisibleForUser,
1114-
"ApproveExpense" MICROFLOW Finance.Tool_ApproveExpense
1115-
DESCRIPTION 'Approve a specific expense report by report number'
1116-
ACCESS UserConfirmationRequired
1117-
);
1127+
{
1128+
TOOL LookupExpenses {
1129+
Microflow: Finance.Tool_LookupExpenses,
1130+
Description: 'List pending expense reports for a department',
1131+
Access: VisibleForUser
1132+
}
1133+
1134+
TOOL ApproveExpense {
1135+
Microflow: Finance.Tool_ApproveExpense,
1136+
Description: 'Approve a specific expense report by report number',
1137+
Access: UserConfirmationRequired
1138+
}
1139+
};
11181140
```
11191141

11201142
#### Step 3: Action Microflow — Unchanged
@@ -1186,12 +1208,13 @@ Always include the source document reference in your answer.
11861208
11871209
Do not make up information that is not in the context.'
11881210
)
1189-
KNOWLEDGE BASES (
1190-
HelpDesk.ProductDocsKB
1191-
COLLECTION 'product-documentation'
1192-
MAX_RESULTS 5
1193-
MIN_SIMILARITY 0.7
1194-
);
1211+
{
1212+
KNOWLEDGE BASE HelpDesk.ProductDocsKB {
1213+
Collection: 'product-documentation',
1214+
MaxResults: 5,
1215+
MinSimilarity: 0.7
1216+
}
1217+
};
11951218
```
11961219

11971220
#### Step 3: Action Microflow — Identical to the Simple Pattern
@@ -1425,17 +1448,25 @@ Always try the knowledge base first before creating a ticket.
14251448
Be patient and ask clarifying questions when the issue is unclear.
14261449
For password resets and access requests, always create a ticket.'
14271450
)
1428-
TOOLS (
1429-
"SearchKB" MICROFLOW ITHelp.Tool_SearchKB
1430-
DESCRIPTION 'Search the knowledge base for articles matching a query'
1431-
ACCESS VisibleForUser,
1432-
"CreateTicket" MICROFLOW ITHelp.Tool_CreateTicket
1433-
DESCRIPTION 'Create a new support ticket with subject, description, and category'
1434-
ACCESS UserConfirmationRequired,
1435-
"GetTicketStatus" MICROFLOW ITHelp.Tool_GetTicketStatus
1436-
DESCRIPTION 'Get current status of an existing support ticket by ID'
1437-
ACCESS VisibleForUser
1438-
);
1451+
{
1452+
TOOL SearchKB {
1453+
Microflow: ITHelp.Tool_SearchKB,
1454+
Description: 'Search the knowledge base for articles matching a query',
1455+
Access: VisibleForUser
1456+
}
1457+
1458+
TOOL CreateTicket {
1459+
Microflow: ITHelp.Tool_CreateTicket,
1460+
Description: 'Create a new support ticket with subject, description, and category',
1461+
Access: UserConfirmationRequired
1462+
}
1463+
1464+
TOOL GetTicketStatus {
1465+
Microflow: ITHelp.Tool_GetTicketStatus,
1466+
Description: 'Get current status of an existing support ticket by ID',
1467+
Access: VisibleForUser
1468+
}
1469+
};
14391470

14401471
-- 6. Chat action microflow — uniform pattern with Call Agent
14411472
CREATE MICROFLOW ITHelp."Chat_ITSupport" (
@@ -1580,7 +1611,7 @@ The combination of `CREATE AGENT` (document definition), tool microflows (busine
15801611

15811612
2. **Contents JSON schema for tools/KB/MCP**: All 4 observed agents in the test3 project have empty `tools`, `knowledgebaseTools`, and MCP arrays. Per the [Agent Editor docs](https://docs.mendix.com/appstore/modules/genai/genai-for-mx/agent-editor/), tools ARE attached to the agent document in the editor — we need to observe the exact JSON shape (keys, nesting, how microflow references are serialized) with a non-empty example before finalizing the writer. Request: user creates an agent with one tool and one KB in Studio Pro so we can capture the BSON.
15821613

1583-
3. **Separate document types for Model, Knowledge Base, and MCP Service**: The Agent Editor treats these as peer document types. To fully support the `TOOLS (...)`, `KNOWLEDGE BASES (...)`, and `MCP SERVICES (...)` clauses, the implementation must also support:
1614+
3. **Separate document types for Model, Knowledge Base, and MCP Service**: The Agent Editor treats these as peer document types. To fully support the `TOOL`, `KNOWLEDGE BASE`, and `MCP SERVICE` blocks inside an agent body, the implementation must also support:
15841615
- `CREATE MODEL` (document with model key constant reference)
15851616
- `CREATE KNOWLEDGE BASE` (document with KB resource key reference)
15861617
- `CREATE CONSUMED MCP SERVICE` (document with endpoint, protocol, credentials microflow)

0 commit comments

Comments
 (0)