thoth-plugin 1.2.4 → 1.2.5
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.
- package/README.md +17 -1
- package/defaults/skill/cal-grid/SKILL.md +168 -0
- package/defaults/skill/cal-grid/cal-grid-template.md +106 -0
- package/defaults/skill/context-discovery/SKILL.md +253 -0
- package/defaults/skill/context-discovery/discovery.prose +143 -0
- package/defaults/skill/context-onboarding/SKILL.md +370 -0
- package/{dist/defaults/skill/_legacy/email-draft/skill.md → defaults/skill/email-draft/SKILL.md} +33 -30
- package/defaults/skill/evening-close/SKILL.md +93 -61
- package/defaults/skill/evening-close/evening-close-template.md +42 -0
- package/{dist/defaults/skill/_legacy → defaults/skill}/gardener/SKILL.md +3 -3
- package/{dist/defaults/skill/_legacy → defaults/skill}/google-chat-scan/SKILL.md +7 -0
- package/{dist/defaults/skill/_legacy → defaults/skill}/leadership-coach/SKILL.md +9 -8
- package/defaults/skill/mail-triage/SKILL.md +272 -15
- package/defaults/skill/mail-triage/mail-triage-template.md +90 -0
- package/defaults/skill/morning-boot/SKILL.md +214 -25
- package/defaults/skill/morning-boot/daily-log-template.md +98 -0
- package/defaults/skill/morning-boot/morning-boot.prose +98 -0
- package/defaults/skill/{_legacy/onboarding → onboarding}/SKILL.md +7 -6
- package/defaults/skill/open-prose/SKILL.md +373 -0
- package/defaults/skill/open-prose/antipatterns.md +852 -0
- package/defaults/skill/open-prose/docs.md +2676 -0
- package/defaults/skill/open-prose/patterns.md +610 -0
- package/defaults/skill/open-prose/prose.md +950 -0
- package/{dist/defaults/skill/_legacy → defaults/skill}/post-meeting-drill/SKILL.md +90 -95
- package/defaults/skill/post-meeting-drill/examples.md +130 -0
- package/defaults/skill/post-meeting-drill/post-meeting-drill-template.md +111 -0
- package/defaults/skill/skill-generator/SKILL.md +217 -0
- package/defaults/skill/skill-generator/skill-template.md +163 -0
- package/defaults/skill/slack-pulse/SKILL.md +211 -14
- package/defaults/skill/slack-pulse/slack-pulse-template.md +98 -0
- package/defaults/skill/slack-write/skill.md +184 -0
- package/defaults/skill/thought-router/SKILL.md +7 -8
- package/dist/cli.js +137 -3
- package/dist/config/schema.d.ts +0 -2
- package/dist/defaults/skill/cal-grid/SKILL.md +168 -0
- package/dist/defaults/skill/cal-grid/cal-grid-template.md +106 -0
- package/dist/defaults/skill/context-discovery/SKILL.md +253 -0
- package/dist/defaults/skill/context-discovery/discovery.prose +143 -0
- package/dist/defaults/skill/context-onboarding/SKILL.md +370 -0
- package/{defaults/skill/_legacy/email-draft/skill.md → dist/defaults/skill/email-draft/SKILL.md} +33 -30
- package/dist/defaults/skill/evening-close/SKILL.md +93 -61
- package/dist/defaults/skill/evening-close/evening-close-template.md +42 -0
- package/{defaults/skill/_legacy → dist/defaults/skill}/gardener/SKILL.md +3 -3
- package/{defaults/skill/_legacy → dist/defaults/skill}/google-chat-scan/SKILL.md +7 -0
- package/{defaults/skill/_legacy → dist/defaults/skill}/leadership-coach/SKILL.md +9 -8
- package/dist/defaults/skill/mail-triage/SKILL.md +272 -15
- package/dist/defaults/skill/mail-triage/mail-triage-template.md +90 -0
- package/dist/defaults/skill/morning-boot/SKILL.md +214 -25
- package/dist/defaults/skill/morning-boot/daily-log-template.md +98 -0
- package/dist/defaults/skill/morning-boot/morning-boot.prose +98 -0
- package/dist/defaults/skill/{_legacy/onboarding → onboarding}/SKILL.md +7 -6
- package/dist/defaults/skill/open-prose/SKILL.md +373 -0
- package/dist/defaults/skill/open-prose/antipatterns.md +852 -0
- package/dist/defaults/skill/open-prose/docs.md +2676 -0
- package/dist/defaults/skill/open-prose/patterns.md +610 -0
- package/dist/defaults/skill/open-prose/prose.md +950 -0
- package/{defaults/skill/_legacy → dist/defaults/skill}/post-meeting-drill/SKILL.md +90 -95
- package/dist/defaults/skill/post-meeting-drill/examples.md +130 -0
- package/dist/defaults/skill/post-meeting-drill/post-meeting-drill-template.md +111 -0
- package/dist/defaults/skill/skill-generator/SKILL.md +217 -0
- package/dist/defaults/skill/skill-generator/skill-template.md +163 -0
- package/dist/defaults/skill/slack-pulse/SKILL.md +211 -14
- package/dist/defaults/skill/slack-pulse/slack-pulse-template.md +98 -0
- package/dist/defaults/skill/slack-write/skill.md +184 -0
- package/dist/defaults/skill/thought-router/SKILL.md +7 -8
- package/dist/hooks/index.d.ts +0 -1
- package/dist/index.js +14 -201
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/sentinel-service.d.ts +0 -1
- package/dist/sdk/test-harness.d.ts +90 -0
- package/dist/shared/index.d.ts +0 -1
- package/dist/specialization/prompt-sections.d.ts +1 -1
- package/package.json +1 -1
- package/defaults/skill/_legacy/cal-grid/SKILL.md +0 -16
- package/defaults/skill/_legacy/skill-generator/SKILL.md +0 -362
- package/dist/defaults/skill/_legacy/cal-grid/SKILL.md +0 -16
- package/dist/defaults/skill/_legacy/skill-generator/SKILL.md +0 -362
- package/dist/hooks/temporal-awareness.d.ts +0 -31
- package/dist/hooks/temporal-awareness.test.d.ts +0 -1
- /package/defaults/skill/{_legacy/capsule-init → capsule-init}/SKILL.md +0 -0
- /package/defaults/skill/{_legacy/cross-linker → cross-linker}/SKILL.md +0 -0
- /package/defaults/skill/{_legacy/gardener → gardener}/confidence-tiers.md +0 -0
- /package/defaults/skill/{_legacy/gardener → gardener}/repair-workflow.md +0 -0
- /package/defaults/skill/{_legacy/handover → handover}/SKILL.md +0 -0
- /package/defaults/skill/{_legacy/interview-prep → interview-prep}/SKILL.md +0 -0
- /package/defaults/skill/{_legacy/link-retrofit → link-retrofit}/SKILL.md +0 -0
- /package/defaults/skill/{_legacy/restore-environment → restore-environment}/SKILL.md +0 -0
- /package/defaults/skill/{_legacy/scorecard-synthesis → scorecard-synthesis}/SKILL.md +0 -0
- /package/defaults/skill/{_legacy/skill-generator → skill-generator}/testing-protocol.md +0 -0
- /package/defaults/skill/{_legacy/system-init → system-init}/SKILL.md +0 -0
- /package/dist/defaults/skill/{_legacy/capsule-init → capsule-init}/SKILL.md +0 -0
- /package/dist/defaults/skill/{_legacy/cross-linker → cross-linker}/SKILL.md +0 -0
- /package/dist/defaults/skill/{_legacy/gardener → gardener}/confidence-tiers.md +0 -0
- /package/dist/defaults/skill/{_legacy/gardener → gardener}/repair-workflow.md +0 -0
- /package/dist/defaults/skill/{_legacy/handover → handover}/SKILL.md +0 -0
- /package/dist/defaults/skill/{_legacy/interview-prep → interview-prep}/SKILL.md +0 -0
- /package/dist/defaults/skill/{_legacy/link-retrofit → link-retrofit}/SKILL.md +0 -0
- /package/dist/defaults/skill/{_legacy/restore-environment → restore-environment}/SKILL.md +0 -0
- /package/dist/defaults/skill/{_legacy/scorecard-synthesis → scorecard-synthesis}/SKILL.md +0 -0
- /package/dist/defaults/skill/{_legacy/skill-generator → skill-generator}/testing-protocol.md +0 -0
- /package/dist/defaults/skill/{_legacy/system-init → system-init}/SKILL.md +0 -0
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
---
|
|
2
|
+
role: best-practices
|
|
3
|
+
summary: |
|
|
4
|
+
see-also:
|
|
5
|
+
- prose.md: Execution semantics, how to run programs
|
|
6
|
+
- docs.md: Full syntax grammar, validation rules
|
|
7
|
+
- antipatterns.md: Patterns to avoid
|
|
8
|
+
created: 2026-01-09
|
|
9
|
+
updated: 2026-01-09
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# OpenProse Design Patterns
|
|
13
|
+
|
|
14
|
+
This document catalogs proven patterns for orchestrating AI agents effectively. Each pattern addresses specific concerns: robustness, cost efficiency, speed, maintainability, or self-improvement capability.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Structural Patterns
|
|
19
|
+
|
|
20
|
+
#### parallel-independent-work
|
|
21
|
+
|
|
22
|
+
When tasks have no data dependencies, execute them concurrently. This maximizes throughput and minimizes wall-clock time.
|
|
23
|
+
|
|
24
|
+
```prose
|
|
25
|
+
# Good: Independent research runs in parallel
|
|
26
|
+
parallel:
|
|
27
|
+
market = session "Research market trends"
|
|
28
|
+
tech = session "Research technology landscape"
|
|
29
|
+
competition = session "Analyze competitor products"
|
|
30
|
+
|
|
31
|
+
session "Synthesize findings"
|
|
32
|
+
context: { market, tech, competition }
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The synthesis session waits for all branches, but total time equals the longest branch rather than the sum of all branches.
|
|
36
|
+
|
|
37
|
+
#### fan-out-fan-in
|
|
38
|
+
|
|
39
|
+
For processing collections, fan out to parallel workers then collect results. Use `parallel for` instead of manual parallel branches.
|
|
40
|
+
|
|
41
|
+
```prose
|
|
42
|
+
let topics = ["AI safety", "interpretability", "alignment", "robustness"]
|
|
43
|
+
|
|
44
|
+
parallel for topic in topics:
|
|
45
|
+
session "Deep dive research on {topic}"
|
|
46
|
+
|
|
47
|
+
session "Create unified report from all research"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This scales naturally with collection size and keeps code DRY.
|
|
51
|
+
|
|
52
|
+
#### pipeline-composition
|
|
53
|
+
|
|
54
|
+
Chain transformations using pipe operators for readable data flow. Each stage has a single responsibility.
|
|
55
|
+
|
|
56
|
+
```prose
|
|
57
|
+
let candidates = session "Generate 10 startup ideas"
|
|
58
|
+
|
|
59
|
+
let result = candidates
|
|
60
|
+
| filter:
|
|
61
|
+
session "Is this idea technically feasible? yes/no"
|
|
62
|
+
context: item
|
|
63
|
+
| map:
|
|
64
|
+
session "Expand this idea into a one-page pitch"
|
|
65
|
+
context: item
|
|
66
|
+
| reduce(best, current):
|
|
67
|
+
session "Compare these two pitches, return the stronger one"
|
|
68
|
+
context: [best, current]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
#### agent-specialization
|
|
72
|
+
|
|
73
|
+
Define agents with focused expertise. Specialized agents produce better results than generalist prompts.
|
|
74
|
+
|
|
75
|
+
```prose
|
|
76
|
+
agent security-reviewer:
|
|
77
|
+
model: sonnet
|
|
78
|
+
prompt: """
|
|
79
|
+
You are a security expert. Focus exclusively on:
|
|
80
|
+
- Authentication and authorization flaws
|
|
81
|
+
- Injection vulnerabilities
|
|
82
|
+
- Data exposure risks
|
|
83
|
+
Ignore style, performance, and other concerns.
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
agent performance-reviewer:
|
|
87
|
+
model: sonnet
|
|
88
|
+
prompt: """
|
|
89
|
+
You are a performance engineer. Focus exclusively on:
|
|
90
|
+
- Algorithmic complexity
|
|
91
|
+
- Memory usage patterns
|
|
92
|
+
- I/O bottlenecks
|
|
93
|
+
Ignore security, style, and other concerns.
|
|
94
|
+
"""
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### reusable-blocks
|
|
98
|
+
|
|
99
|
+
Extract repeated workflows into parameterized blocks. Blocks are the functions of OpenProse.
|
|
100
|
+
|
|
101
|
+
```prose
|
|
102
|
+
block review-and-revise(artifact, criteria):
|
|
103
|
+
let feedback = session "Review {artifact} against {criteria}"
|
|
104
|
+
session "Revise {artifact} based on feedback"
|
|
105
|
+
context: feedback
|
|
106
|
+
|
|
107
|
+
# Reuse the pattern
|
|
108
|
+
do review-and-revise("the architecture doc", "clarity and completeness")
|
|
109
|
+
do review-and-revise("the API design", "consistency and usability")
|
|
110
|
+
do review-and-revise("the test plan", "coverage and edge cases")
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Robustness Patterns
|
|
116
|
+
|
|
117
|
+
#### bounded-iteration
|
|
118
|
+
|
|
119
|
+
Always constrain loops with `max:` to prevent runaway execution. Even well-crafted conditions can fail to terminate.
|
|
120
|
+
|
|
121
|
+
```prose
|
|
122
|
+
# Good: Explicit upper bound
|
|
123
|
+
loop until **all tests pass** (max: 20):
|
|
124
|
+
session "Identify and fix the next failing test"
|
|
125
|
+
|
|
126
|
+
# The program will terminate even if tests never fully pass
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### graceful-degradation
|
|
130
|
+
|
|
131
|
+
Use `on-fail: "continue"` when partial results are acceptable. Collect what you can rather than failing entirely.
|
|
132
|
+
|
|
133
|
+
```prose
|
|
134
|
+
parallel (on-fail: "continue"):
|
|
135
|
+
primary = session "Query primary data source"
|
|
136
|
+
backup = session "Query backup data source"
|
|
137
|
+
cache = session "Check local cache"
|
|
138
|
+
|
|
139
|
+
# Continue with whatever succeeded
|
|
140
|
+
session "Merge available data"
|
|
141
|
+
context: { primary, backup, cache }
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### retry-with-backoff
|
|
145
|
+
|
|
146
|
+
External services fail transiently. Retry with exponential backoff to handle rate limits and temporary outages.
|
|
147
|
+
|
|
148
|
+
```prose
|
|
149
|
+
session "Call external API"
|
|
150
|
+
retry: 5
|
|
151
|
+
backoff: "exponential"
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
For critical paths, combine retry with fallback:
|
|
155
|
+
|
|
156
|
+
```prose
|
|
157
|
+
try:
|
|
158
|
+
session "Call primary API"
|
|
159
|
+
retry: 3
|
|
160
|
+
backoff: "exponential"
|
|
161
|
+
catch:
|
|
162
|
+
session "Use fallback data source"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### error-context-capture
|
|
166
|
+
|
|
167
|
+
Capture error context for intelligent recovery. The error variable provides information for diagnostic or remediation sessions.
|
|
168
|
+
|
|
169
|
+
```prose
|
|
170
|
+
try:
|
|
171
|
+
session "Deploy to production"
|
|
172
|
+
catch as err:
|
|
173
|
+
session "Analyze deployment failure and suggest fixes"
|
|
174
|
+
context: err
|
|
175
|
+
session "Attempt automatic remediation"
|
|
176
|
+
context: err
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### defensive-context
|
|
180
|
+
|
|
181
|
+
Validate assumptions before expensive operations. Cheap checks prevent wasted computation.
|
|
182
|
+
|
|
183
|
+
```prose
|
|
184
|
+
let prereqs = session "Check all prerequisites: API keys, permissions, dependencies"
|
|
185
|
+
|
|
186
|
+
if **prerequisites are not met**:
|
|
187
|
+
session "Report missing prerequisites and exit"
|
|
188
|
+
context: prereqs
|
|
189
|
+
throw "Prerequisites not satisfied"
|
|
190
|
+
|
|
191
|
+
# Expensive operations only run if prereqs pass
|
|
192
|
+
session "Execute main workflow"
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Cost Efficiency Patterns
|
|
198
|
+
|
|
199
|
+
#### model-tiering
|
|
200
|
+
|
|
201
|
+
Match model capability to task complexity. Use haiku for simple tasks, sonnet for moderate complexity, opus for deep reasoning.
|
|
202
|
+
|
|
203
|
+
```prose
|
|
204
|
+
agent classifier:
|
|
205
|
+
model: haiku # Fast, cheap classification
|
|
206
|
+
prompt: "You categorize items into predefined buckets"
|
|
207
|
+
|
|
208
|
+
agent analyst:
|
|
209
|
+
model: sonnet # Balanced analysis
|
|
210
|
+
prompt: "You analyze data and identify patterns"
|
|
211
|
+
|
|
212
|
+
agent strategist:
|
|
213
|
+
model: opus # Complex reasoning
|
|
214
|
+
prompt: "You synthesize information into strategic recommendations"
|
|
215
|
+
|
|
216
|
+
# Workflow uses appropriate model per stage
|
|
217
|
+
let category = session: classifier
|
|
218
|
+
prompt: "Classify this support ticket: {ticket}"
|
|
219
|
+
|
|
220
|
+
if **category is complex technical issue**:
|
|
221
|
+
session: strategist
|
|
222
|
+
prompt: "Develop resolution strategy"
|
|
223
|
+
else:
|
|
224
|
+
session: analyst
|
|
225
|
+
prompt: "Suggest standard resolution"
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### context-minimization
|
|
229
|
+
|
|
230
|
+
Pass only relevant context. Large contexts slow processing and increase costs.
|
|
231
|
+
|
|
232
|
+
```prose
|
|
233
|
+
# Bad: Passing everything
|
|
234
|
+
session "Write executive summary"
|
|
235
|
+
context: [raw_data, analysis, methodology, appendices, references]
|
|
236
|
+
|
|
237
|
+
# Good: Pass only what's needed
|
|
238
|
+
let key_findings = session "Extract key findings from analysis"
|
|
239
|
+
context: analysis
|
|
240
|
+
|
|
241
|
+
session "Write executive summary"
|
|
242
|
+
context: key_findings
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
#### early-termination
|
|
246
|
+
|
|
247
|
+
Exit loops as soon as the goal is achieved. Don't iterate unnecessarily.
|
|
248
|
+
|
|
249
|
+
```prose
|
|
250
|
+
# The condition is checked each iteration
|
|
251
|
+
loop until **solution found and verified** (max: 10):
|
|
252
|
+
session "Generate potential solution"
|
|
253
|
+
session "Verify solution correctness"
|
|
254
|
+
# Exits immediately when condition is met, not after max iterations
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### race-for-speed
|
|
258
|
+
|
|
259
|
+
When any valid result suffices, race multiple approaches and take the first success.
|
|
260
|
+
|
|
261
|
+
```prose
|
|
262
|
+
parallel ("first"):
|
|
263
|
+
session "Try algorithm A"
|
|
264
|
+
session "Try algorithm B"
|
|
265
|
+
session "Try algorithm C"
|
|
266
|
+
|
|
267
|
+
# Continues as soon as any approach completes
|
|
268
|
+
session "Use winning result"
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
#### batch-similar-work
|
|
272
|
+
|
|
273
|
+
Group similar operations to amortize overhead. One session with structured output beats many small sessions.
|
|
274
|
+
|
|
275
|
+
```prose
|
|
276
|
+
# Inefficient: Many small sessions
|
|
277
|
+
for file in files:
|
|
278
|
+
session "Analyze {file}"
|
|
279
|
+
|
|
280
|
+
# Efficient: Batch analysis
|
|
281
|
+
session "Analyze all files and return structured findings for each"
|
|
282
|
+
context: files
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Self-Improvement Patterns
|
|
288
|
+
|
|
289
|
+
#### iterative-refinement
|
|
290
|
+
|
|
291
|
+
Use feedback loops to progressively improve outputs. Each iteration builds on the previous.
|
|
292
|
+
|
|
293
|
+
```prose
|
|
294
|
+
let draft = session "Create initial draft"
|
|
295
|
+
|
|
296
|
+
loop until **draft meets quality bar** (max: 5):
|
|
297
|
+
let critique = session "Critically evaluate this draft"
|
|
298
|
+
context: draft
|
|
299
|
+
draft = session "Improve draft based on critique"
|
|
300
|
+
context: [draft, critique]
|
|
301
|
+
|
|
302
|
+
session "Finalize and publish"
|
|
303
|
+
context: draft
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
#### multi-perspective-review
|
|
307
|
+
|
|
308
|
+
Gather diverse viewpoints before synthesis. Different lenses catch different issues.
|
|
309
|
+
|
|
310
|
+
```prose
|
|
311
|
+
parallel:
|
|
312
|
+
user_perspective = session "Evaluate from end-user viewpoint"
|
|
313
|
+
tech_perspective = session "Evaluate from engineering viewpoint"
|
|
314
|
+
business_perspective = session "Evaluate from business viewpoint"
|
|
315
|
+
|
|
316
|
+
session "Synthesize feedback and prioritize improvements"
|
|
317
|
+
context: { user_perspective, tech_perspective, business_perspective }
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
#### adversarial-validation
|
|
321
|
+
|
|
322
|
+
Use one agent to challenge another's work. Adversarial pressure improves robustness.
|
|
323
|
+
|
|
324
|
+
```prose
|
|
325
|
+
let proposal = session "Generate proposal"
|
|
326
|
+
|
|
327
|
+
let critique = session "Find flaws and weaknesses in this proposal"
|
|
328
|
+
context: proposal
|
|
329
|
+
|
|
330
|
+
let defense = session "Address each critique with evidence or revisions"
|
|
331
|
+
context: [proposal, critique]
|
|
332
|
+
|
|
333
|
+
session "Produce final proposal incorporating valid critiques"
|
|
334
|
+
context: [proposal, critique, defense]
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
#### consensus-building
|
|
338
|
+
|
|
339
|
+
For critical decisions, require agreement between independent evaluators.
|
|
340
|
+
|
|
341
|
+
```prose
|
|
342
|
+
parallel:
|
|
343
|
+
eval1 = session "Independently evaluate the solution"
|
|
344
|
+
eval2 = session "Independently evaluate the solution"
|
|
345
|
+
eval3 = session "Independently evaluate the solution"
|
|
346
|
+
|
|
347
|
+
loop until **evaluators agree** (max: 3):
|
|
348
|
+
session "Identify points of disagreement"
|
|
349
|
+
context: { eval1, eval2, eval3 }
|
|
350
|
+
parallel:
|
|
351
|
+
eval1 = session "Reconsider position given other perspectives"
|
|
352
|
+
context: { eval1, eval2, eval3 }
|
|
353
|
+
eval2 = session "Reconsider position given other perspectives"
|
|
354
|
+
context: { eval1, eval2, eval3 }
|
|
355
|
+
eval3 = session "Reconsider position given other perspectives"
|
|
356
|
+
context: { eval1, eval2, eval3 }
|
|
357
|
+
|
|
358
|
+
session "Document consensus decision"
|
|
359
|
+
context: { eval1, eval2, eval3 }
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## Maintainability Patterns
|
|
365
|
+
|
|
366
|
+
#### descriptive-agent-names
|
|
367
|
+
|
|
368
|
+
Name agents for their role, not their implementation. Names should convey purpose.
|
|
369
|
+
|
|
370
|
+
```prose
|
|
371
|
+
# Good: Role-based naming
|
|
372
|
+
agent code-reviewer:
|
|
373
|
+
agent technical-writer:
|
|
374
|
+
agent data-analyst:
|
|
375
|
+
|
|
376
|
+
# Bad: Implementation-based naming
|
|
377
|
+
agent opus-agent:
|
|
378
|
+
agent session-1-handler:
|
|
379
|
+
agent helper:
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
#### prompt-as-contract
|
|
383
|
+
|
|
384
|
+
Write prompts that specify expected inputs and outputs. Clear contracts prevent misunderstandings.
|
|
385
|
+
|
|
386
|
+
```prose
|
|
387
|
+
agent json-extractor:
|
|
388
|
+
model: haiku
|
|
389
|
+
prompt: """
|
|
390
|
+
Extract structured data from text.
|
|
391
|
+
|
|
392
|
+
Input: Unstructured text containing entity information
|
|
393
|
+
Output: JSON object with fields: name, date, amount, status
|
|
394
|
+
|
|
395
|
+
If a field cannot be determined, use null.
|
|
396
|
+
Never invent information not present in the input.
|
|
397
|
+
"""
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
#### separation-of-concerns
|
|
401
|
+
|
|
402
|
+
Each session should do one thing well. Combine simple sessions rather than creating complex ones.
|
|
403
|
+
|
|
404
|
+
```prose
|
|
405
|
+
# Good: Single responsibility per session
|
|
406
|
+
let data = session "Fetch and validate input data"
|
|
407
|
+
let analysis = session "Analyze data for patterns"
|
|
408
|
+
context: data
|
|
409
|
+
let recommendations = session "Generate recommendations from analysis"
|
|
410
|
+
context: analysis
|
|
411
|
+
session "Format recommendations as report"
|
|
412
|
+
context: recommendations
|
|
413
|
+
|
|
414
|
+
# Bad: God session
|
|
415
|
+
session "Fetch data, analyze it, generate recommendations, and format a report"
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
#### explicit-context-flow
|
|
419
|
+
|
|
420
|
+
Make data flow visible through explicit context passing. Avoid relying on implicit conversation history.
|
|
421
|
+
|
|
422
|
+
```prose
|
|
423
|
+
# Good: Explicit flow
|
|
424
|
+
let step1 = session "First step"
|
|
425
|
+
let step2 = session "Second step"
|
|
426
|
+
context: step1
|
|
427
|
+
let step3 = session "Third step"
|
|
428
|
+
context: [step1, step2]
|
|
429
|
+
|
|
430
|
+
# Bad: Implicit flow (relies on conversation state)
|
|
431
|
+
session "First step"
|
|
432
|
+
session "Second step using previous results"
|
|
433
|
+
session "Third step using all previous"
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
## Performance Patterns
|
|
439
|
+
|
|
440
|
+
#### lazy-evaluation
|
|
441
|
+
|
|
442
|
+
Defer expensive operations until their results are needed. Don't compute what might not be used.
|
|
443
|
+
|
|
444
|
+
```prose
|
|
445
|
+
session "Assess situation"
|
|
446
|
+
|
|
447
|
+
if **detailed analysis needed**:
|
|
448
|
+
# Expensive operations only when necessary
|
|
449
|
+
parallel:
|
|
450
|
+
deep_analysis = session "Perform deep analysis"
|
|
451
|
+
model: opus
|
|
452
|
+
historical = session "Gather historical comparisons"
|
|
453
|
+
session "Comprehensive report"
|
|
454
|
+
context: { deep_analysis, historical }
|
|
455
|
+
else:
|
|
456
|
+
session "Quick summary"
|
|
457
|
+
model: haiku
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
#### progressive-disclosure
|
|
461
|
+
|
|
462
|
+
Start with fast, cheap operations. Escalate to expensive ones only when needed.
|
|
463
|
+
|
|
464
|
+
```prose
|
|
465
|
+
# Tier 1: Fast screening (haiku)
|
|
466
|
+
let initial = session "Quick assessment"
|
|
467
|
+
model: haiku
|
|
468
|
+
|
|
469
|
+
if **needs deeper review**:
|
|
470
|
+
# Tier 2: Moderate analysis (sonnet)
|
|
471
|
+
let detailed = session "Detailed analysis"
|
|
472
|
+
model: sonnet
|
|
473
|
+
context: initial
|
|
474
|
+
|
|
475
|
+
if **needs expert review**:
|
|
476
|
+
# Tier 3: Deep reasoning (opus)
|
|
477
|
+
session "Expert-level analysis"
|
|
478
|
+
model: opus
|
|
479
|
+
context: [initial, detailed]
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
#### work-stealing
|
|
483
|
+
|
|
484
|
+
Use `parallel ("any", count: N)` to get results as fast as possible from a pool of workers.
|
|
485
|
+
|
|
486
|
+
```prose
|
|
487
|
+
# Get 3 good ideas as fast as possible from 5 parallel attempts
|
|
488
|
+
parallel ("any", count: 3, on-fail: "ignore"):
|
|
489
|
+
session "Generate creative solution approach 1"
|
|
490
|
+
session "Generate creative solution approach 2"
|
|
491
|
+
session "Generate creative solution approach 3"
|
|
492
|
+
session "Generate creative solution approach 4"
|
|
493
|
+
session "Generate creative solution approach 5"
|
|
494
|
+
|
|
495
|
+
session "Select best from the first 3 completed"
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
---
|
|
499
|
+
|
|
500
|
+
## Composition Patterns
|
|
501
|
+
|
|
502
|
+
#### workflow-template
|
|
503
|
+
|
|
504
|
+
Create blocks that encode entire workflow patterns. Instantiate with different parameters.
|
|
505
|
+
|
|
506
|
+
```prose
|
|
507
|
+
block research-report(topic, depth):
|
|
508
|
+
let research = session "Research {topic} at {depth} level"
|
|
509
|
+
let analysis = session "Analyze findings about {topic}"
|
|
510
|
+
context: research
|
|
511
|
+
let report = session "Write {depth}-level report on {topic}"
|
|
512
|
+
context: [research, analysis]
|
|
513
|
+
|
|
514
|
+
# Instantiate for different needs
|
|
515
|
+
do research-report("market trends", "executive")
|
|
516
|
+
do research-report("technical architecture", "detailed")
|
|
517
|
+
do research-report("competitive landscape", "comprehensive")
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
#### middleware-pattern
|
|
521
|
+
|
|
522
|
+
Wrap sessions with cross-cutting concerns like logging, timing, or validation.
|
|
523
|
+
|
|
524
|
+
```prose
|
|
525
|
+
block with-validation(task, validator):
|
|
526
|
+
let result = session "{task}"
|
|
527
|
+
let valid = session "{validator}"
|
|
528
|
+
context: result
|
|
529
|
+
if **validation failed**:
|
|
530
|
+
throw "Validation failed for: {task}"
|
|
531
|
+
|
|
532
|
+
do with-validation("Generate SQL query", "Check SQL for injection vulnerabilities")
|
|
533
|
+
do with-validation("Generate config file", "Validate config syntax")
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
#### circuit-breaker
|
|
537
|
+
|
|
538
|
+
After repeated failures, stop trying and fail fast. Prevents cascading failures.
|
|
539
|
+
|
|
540
|
+
```prose
|
|
541
|
+
let failures = 0
|
|
542
|
+
let max_failures = 3
|
|
543
|
+
|
|
544
|
+
loop while **service needed and failures < max_failures** (max: 10):
|
|
545
|
+
try:
|
|
546
|
+
session "Call external service"
|
|
547
|
+
# Reset on success
|
|
548
|
+
failures = 0
|
|
549
|
+
catch:
|
|
550
|
+
failures = failures + 1
|
|
551
|
+
if **failures >= max_failures**:
|
|
552
|
+
session "Circuit open - using fallback"
|
|
553
|
+
throw "Service unavailable"
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
---
|
|
557
|
+
|
|
558
|
+
## Observability Patterns
|
|
559
|
+
|
|
560
|
+
#### checkpoint-narration
|
|
561
|
+
|
|
562
|
+
For long workflows, emit progress markers. Helps with debugging and monitoring.
|
|
563
|
+
|
|
564
|
+
```prose
|
|
565
|
+
session "Phase 1: Data Collection"
|
|
566
|
+
# ... collection work ...
|
|
567
|
+
|
|
568
|
+
session "Phase 2: Analysis"
|
|
569
|
+
# ... analysis work ...
|
|
570
|
+
|
|
571
|
+
session "Phase 3: Report Generation"
|
|
572
|
+
# ... report work ...
|
|
573
|
+
|
|
574
|
+
session "Phase 4: Quality Assurance"
|
|
575
|
+
# ... QA work ...
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
#### structured-output-contracts
|
|
579
|
+
|
|
580
|
+
Request structured outputs that can be reliably parsed and validated.
|
|
581
|
+
|
|
582
|
+
```prose
|
|
583
|
+
agent structured-reviewer:
|
|
584
|
+
model: sonnet
|
|
585
|
+
prompt: """
|
|
586
|
+
Always respond with this exact JSON structure:
|
|
587
|
+
{
|
|
588
|
+
"verdict": "pass" | "fail" | "needs_review",
|
|
589
|
+
"issues": [{"severity": "high"|"medium"|"low", "description": "..."}],
|
|
590
|
+
"suggestions": ["..."]
|
|
591
|
+
}
|
|
592
|
+
"""
|
|
593
|
+
|
|
594
|
+
let review = session: structured-reviewer
|
|
595
|
+
prompt: "Review this code for security issues"
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
---
|
|
599
|
+
|
|
600
|
+
## Summary
|
|
601
|
+
|
|
602
|
+
The most effective OpenProse programs combine these patterns:
|
|
603
|
+
|
|
604
|
+
1. **Structure**: Parallelize independent work, use blocks for reuse
|
|
605
|
+
2. **Robustness**: Bound loops, handle errors, retry transient failures
|
|
606
|
+
3. **Efficiency**: Tier models, minimize context, terminate early
|
|
607
|
+
4. **Quality**: Iterate, get multiple perspectives, validate adversarially
|
|
608
|
+
5. **Maintainability**: Name clearly, separate concerns, make flow explicit
|
|
609
|
+
|
|
610
|
+
Choose patterns based on your specific constraints. A quick prototype prioritizes speed over robustness. A production workflow prioritizes reliability over cost. A research exploration prioritizes thoroughness over efficiency.
|