You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: agent-context/skills/metaobjects-prompts/references/csharp.md
+26-21Lines changed: 26 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,18 @@
1
1
# C# parser-on-receipt
2
2
3
-
For every `template.output`, `MetaObjects.Codegen`'s `OutputParserGenerator` emits a
4
-
**typed parser** that validates an LLM/raw response against the template's
5
-
`@payloadRef` payload record. This is the receive side only — codegen emits **no**
6
-
provider/LLM-call layer; you compose the call yourself. The payload record comes from
7
-
the payload generator, so the parser and the payload VO can't silently drift.
3
+
For every RESPONDING `template.prompt` — one declaring `@responseRef` —
4
+
`MetaObjects.Codegen`'s `OutputParserGenerator` emits a **typed parser** that validates
5
+
a model's reply against that shape. ADR-0052: the tier binds `@responseRef`, never
6
+
`@payloadRef` (which types the request the prompt renders outbound), and a
7
+
`template.output` gets no parser at all. This is the receive side only — codegen emits
8
+
**no** provider/LLM-call layer; you compose the call yourself. C# names records after the
9
+
resolved VALUE OBJECT, so the response record simply IS that VO's record — no second
10
+
naming convention, and the parser and the record can't silently drift.
8
11
9
12
## Contents
10
13
- Wire the generator
11
14
- What it emits
12
-
- The output-format prompt fragment (FR-010)
15
+
- The response-format prompt fragment (FR-010)
13
16
- The three-step consumer pattern
14
17
- Recommended LLM caller (bring-your-own)
15
18
- Consumer dependency
@@ -27,12 +30,14 @@ dotnet meta gen ./metadata --out ./Generated --namespace Acme.Blog
27
30
28
31
## What it emits
29
32
30
-
Per `template.output`, `dotnet meta gen` writes one `<TemplateName>.output.cs` with a
31
-
static `<TemplateName>Parser` following the .NET BCL `Parse`/`TryParse` dual API —
33
+
Per responding `template.prompt`, `dotnet meta gen` writes one
34
+
`<PromptName>.response.cs` with a static `<PromptName>Parser` following the .NET BCL
35
+
`Parse`/`TryParse` dual API. The strict tier is JSON-only — an `@responseFormat: xml`
36
+
reply gets the tolerant extract and neither `Parse` nor `TryParse` —
32
37
`Parse` throws, `TryParse` returns a bool plus an out-error:
33
38
34
39
```csharp
35
-
// generated <TemplateName>.output.cs (shape)
40
+
// generated <PromptName>.response.cs (shape)
36
41
publicstaticclassNpcResponseParser
37
42
{
38
43
/// <exceptioncref="JsonException">malformed JSON or schema mismatch.</exception>
@@ -53,25 +58,25 @@ generator also emits a tolerant `Extract(string[, ExtractOptions])` (self-contai
53
58
components) returning an `ExtractionResult` with a nullable `<Payload>Extracted` mirror
54
59
— a classified per-field report rather than a throw.
55
60
56
-
## The output-format prompt fragment (FR-010)
61
+
## The response-format prompt fragment (FR-010)
57
62
58
-
For every json/xml-format `template.output`, `MetaObjects.Codegen`'s
59
-
`OutputPromptGenerator` (stable name `output-prompt-generator`) emits a
60
-
`<TemplateName>.prompt.cs` declaring a static `<TemplateName>Prompt` class with a
61
-
`RenderFormat()` / `RenderFormat(PromptOverrides)` pair, backed by the render
62
-
engine's `OutputFormatRenderer` — the "produce your answer like this" fragment for
63
-
the model. It runs as part of the same `dotnet meta gen` invocation as the payload
63
+
For every responding `template.prompt`, `MetaObjects.Codegen`'s `OutputPromptGenerator`
64
+
(stable name `output-prompt-generator`) emits a `<PromptName>.responseFormat.cs`
65
+
declaring a static `<PromptName>ResponseFormat` class with a `RenderFormat()` /
66
+
`RenderFormat(PromptOverrides)` pair, backed by the render engine's
67
+
`OutputFormatRenderer` — the "produce your answer like this" fragment for the model. It runs as part of the same `dotnet meta gen` invocation as the payload
64
68
and parser generators:
65
69
66
70
```bash
67
71
dotnet meta gen ./metadata --out ./Generated --namespace Acme.Blog
68
72
```
69
73
70
-
`@promptStyle` on the `template.output` (`guide` default / `inline` / `exampleOnly`)
71
-
controls the fragment's presentation; guidance is never emitted as comments. Skipped
72
-
for `template.prompt` nodes, non-json/xml `@format`, and an unresolved
73
-
`@payloadRef` — the same skip contract as the parser generator. The baked spec's
74
-
root name is the payload class name, agreeing with the parser's root.
74
+
`@promptStyle` on the `template.prompt` (`guide` default / `inline` / `exampleOnly`)
75
+
controls the fragment's presentation; guidance is never emitted as comments. Skipped for
76
+
`template.output` nodes and an unresolved `@responseRef` — the same skip contract as the
77
+
parser generator. There is NO format gate: the old `@format ∈ {json,xml}` test read the
78
+
syntax of the outbound body to decide whether to describe the reply. The baked spec's
79
+
root name is the response record's, agreeing with the parser's root.
0 commit comments