coaiajs 0.3.0 → 0.3.2

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.
Files changed (179) hide show
  1. package/KINSHIP.md +1 -1
  2. package/README.md +191 -75
  3. package/dist/mcp/config.d.ts.map +1 -0
  4. package/dist/mcp/config.js +0 -2
  5. package/dist/mcp/config.js.map +1 -0
  6. package/dist/mcp/prompts.d.ts.map +1 -0
  7. package/dist/mcp/prompts.js.map +1 -0
  8. package/dist/mcp/resources.d.ts.map +1 -0
  9. package/dist/mcp/resources.js.map +1 -0
  10. package/dist/mcp/server.d.ts.map +1 -0
  11. package/dist/mcp/server.js +1 -1
  12. package/dist/mcp/server.js.map +1 -0
  13. package/dist/mcp/tools/coaiapy-tools.d.ts.map +1 -0
  14. package/dist/mcp/tools/coaiapy-tools.js.map +1 -0
  15. package/dist/mcp/tools/index.d.ts.map +1 -0
  16. package/dist/mcp/tools/index.js.map +1 -0
  17. package/dist/src/audio.d.ts.map +1 -0
  18. package/dist/src/audio.js.map +1 -0
  19. package/dist/src/cli-helpers.d.ts.map +1 -0
  20. package/dist/src/cli-helpers.js.map +1 -0
  21. package/dist/src/cli.d.ts.map +1 -0
  22. package/dist/src/cli.js +1 -0
  23. package/dist/src/cli.js.map +1 -0
  24. package/dist/src/config.d.ts.map +1 -0
  25. package/dist/src/config.js.map +1 -0
  26. package/dist/src/environment.d.ts.map +1 -0
  27. package/dist/src/environment.js.map +1 -0
  28. package/dist/src/github.d.ts.map +1 -0
  29. package/dist/src/github.js.map +1 -0
  30. package/dist/src/index.d.ts +1 -0
  31. package/dist/src/index.d.ts.map +1 -0
  32. package/dist/src/index.js +1 -0
  33. package/dist/src/index.js.map +1 -0
  34. package/dist/src/langfuse/client.d.ts.map +1 -0
  35. package/dist/src/langfuse/client.js.map +1 -0
  36. package/dist/src/langfuse/comments.d.ts.map +1 -0
  37. package/dist/src/langfuse/comments.js.map +1 -0
  38. package/dist/src/langfuse/datasets.d.ts.map +1 -0
  39. package/dist/src/langfuse/datasets.js.map +1 -0
  40. package/dist/src/langfuse/index.d.ts +1 -0
  41. package/dist/src/langfuse/index.d.ts.map +1 -0
  42. package/dist/src/langfuse/index.js.map +1 -0
  43. package/dist/src/langfuse/media.d.ts.map +1 -0
  44. package/dist/src/langfuse/media.js.map +1 -0
  45. package/dist/src/langfuse/observations.d.ts.map +1 -0
  46. package/dist/src/langfuse/observations.js.map +1 -0
  47. package/dist/src/langfuse/prompts.d.ts +5 -1
  48. package/dist/src/langfuse/prompts.d.ts.map +1 -0
  49. package/dist/src/langfuse/prompts.js +16 -3
  50. package/dist/src/langfuse/prompts.js.map +1 -0
  51. package/dist/src/langfuse/scores.d.ts.map +1 -0
  52. package/dist/src/langfuse/scores.js.map +1 -0
  53. package/dist/src/langfuse/traces.d.ts.map +1 -0
  54. package/dist/src/langfuse/traces.js.map +1 -0
  55. package/dist/src/llm.d.ts.map +1 -0
  56. package/dist/src/llm.js.map +1 -0
  57. package/dist/src/narrative/graph-manager.d.ts.map +1 -0
  58. package/dist/src/narrative/graph-manager.js.map +1 -0
  59. package/dist/src/narrative/index.d.ts.map +1 -0
  60. package/dist/src/narrative/index.js.map +1 -0
  61. package/dist/src/narrative/markdown-export.d.ts.map +1 -0
  62. package/dist/src/narrative/markdown-export.js.map +1 -0
  63. package/dist/src/narrative/tool-definitions.d.ts.map +1 -0
  64. package/dist/src/narrative/tool-definitions.js.map +1 -0
  65. package/dist/src/narrative/tool-handlers.d.ts.map +1 -0
  66. package/dist/src/narrative/tool-handlers.js.map +1 -0
  67. package/dist/src/narrative/types.d.ts.map +1 -0
  68. package/dist/src/narrative/types.js.map +1 -0
  69. package/dist/src/narrative/validation.d.ts.map +1 -0
  70. package/dist/src/narrative/validation.js.map +1 -0
  71. package/dist/src/pde/index.d.ts.map +1 -0
  72. package/dist/src/pde/index.js.map +1 -0
  73. package/dist/src/pde/mcp-handlers.d.ts.map +1 -0
  74. package/dist/src/pde/mcp-handlers.js.map +1 -0
  75. package/dist/src/pde/mcp-tools.d.ts.map +1 -0
  76. package/dist/src/pde/mcp-tools.js.map +1 -0
  77. package/dist/src/pde/session-manager.d.ts.map +1 -0
  78. package/dist/src/pde/session-manager.js.map +1 -0
  79. package/dist/src/pde/stc-mapper.d.ts.map +1 -0
  80. package/dist/src/pde/stc-mapper.js.map +1 -0
  81. package/dist/src/pipeline/index.d.ts.map +1 -0
  82. package/dist/src/pipeline/index.js.map +1 -0
  83. package/dist/src/pipeline/template-engine.d.ts.map +1 -0
  84. package/dist/src/pipeline/template-engine.js.map +1 -0
  85. package/dist/src/planning/index.d.ts.map +1 -0
  86. package/dist/src/planning/index.js.map +1 -0
  87. package/dist/src/planning/mcp-handlers.d.ts.map +1 -0
  88. package/dist/src/planning/mcp-handlers.js.map +1 -0
  89. package/dist/src/planning/mcp-tools.d.ts.map +1 -0
  90. package/dist/src/planning/mcp-tools.js.map +1 -0
  91. package/dist/src/planning/plan-parser.d.ts.map +1 -0
  92. package/dist/src/planning/plan-parser.js.map +1 -0
  93. package/dist/src/redis.d.ts.map +1 -0
  94. package/dist/src/redis.js.map +1 -0
  95. package/dist/src/types.d.ts.map +1 -0
  96. package/dist/src/types.js.map +1 -0
  97. package/dist/src/version.d.ts.map +1 -0
  98. package/dist/src/version.js.map +1 -0
  99. package/llms-full.txt +361 -0
  100. package/llms.txt +43 -0
  101. package/package.json +79 -12
  102. package/.claude/settings.local.json +0 -17
  103. package/.claude-plugin/marketplace.json +0 -26
  104. package/articles/academic/NOTES.md +0 -1
  105. package/articles/academic/README.md +0 -1
  106. package/articles/academic/creative-orientation-vs-problem-solving.md +0 -177
  107. package/articles/academic/jsonl-knowledge-graphs-agent-memory.md +0 -142
  108. package/articles/academic/langfuse-observability-llm-pipelines.md +0 -144
  109. package/articles/academic/medicine-wheel-software-architecture.md +0 -163
  110. package/articles/academic/mmot-autonomous-agents.md +0 -156
  111. package/articles/academic/model-context-protocol-interagent.md +0 -161
  112. package/articles/academic/pde-prompt-decomposition.md +0 -186
  113. package/articles/academic/structural-tension-in-ai-agents.md +0 -134
  114. package/articles/reviews/mcp-protocol-design-review.md +0 -170
  115. package/articles/reviews/observability-ai-systems-review.md +0 -176
  116. package/articles/reviews/prompt-engineering-decomposition-review.md +0 -184
  117. package/articles/surveys/agent-orchestration-survey.md +0 -186
  118. package/articles/surveys/knowledge-graph-storage-survey.md +0 -204
  119. package/articles/surveys/structural-tension-methodology-survey.md +0 -154
  120. package/articles/technical/aws-sdk-v3-polly.md +0 -270
  121. package/articles/technical/commander-cli-framework.md +0 -262
  122. package/articles/technical/dotenv-config-patterns.md +0 -360
  123. package/articles/technical/ioredis-vs-redis.md +0 -142
  124. package/articles/technical/langfuse-js-sdk-vs-rest.md +0 -191
  125. package/articles/technical/mcp-sdk-typescript.md +0 -291
  126. package/articles/technical/octokit-github-api.md +0 -293
  127. package/articles/technical/openai-sdk-modern.md +0 -231
  128. package/articles/technical/yaml-parsing-node.md +0 -266
  129. package/articles/technical/zod-runtime-validation.md +0 -212
  130. package/coaiajs-langfuse-claude-plugin/.claude-plugin/marketplace.json +0 -16
  131. package/coaiajs-langfuse-claude-plugin/.claude-plugin/plugin.json +0 -10
  132. package/coaiajs-langfuse-claude-plugin/.mcp.json +0 -8
  133. package/coaiajs-langfuse-claude-plugin/README.md +0 -60
  134. package/mcp/config.ts +0 -225
  135. package/mcp/prompts.ts +0 -131
  136. package/mcp/resources.ts +0 -84
  137. package/mcp/server.ts +0 -519
  138. package/mcp/tools/coaiapy-tools.ts +0 -366
  139. package/mcp/tools/index.ts +0 -4
  140. package/src/audio.ts +0 -76
  141. package/src/cli-helpers.ts +0 -86
  142. package/src/cli.ts +0 -1261
  143. package/src/config.ts +0 -207
  144. package/src/environment.ts +0 -171
  145. package/src/github.ts +0 -143
  146. package/src/index.ts +0 -82
  147. package/src/langfuse/client.ts +0 -105
  148. package/src/langfuse/comments.ts +0 -52
  149. package/src/langfuse/datasets.ts +0 -178
  150. package/src/langfuse/index.ts +0 -37
  151. package/src/langfuse/media.ts +0 -193
  152. package/src/langfuse/observations.ts +0 -155
  153. package/src/langfuse/prompts.ts +0 -157
  154. package/src/langfuse/scores.ts +0 -456
  155. package/src/langfuse/traces.ts +0 -353
  156. package/src/llm.ts +0 -106
  157. package/src/narrative/graph-manager.ts +0 -1358
  158. package/src/narrative/index.ts +0 -188
  159. package/src/narrative/markdown-export.ts +0 -535
  160. package/src/narrative/tool-definitions.ts +0 -635
  161. package/src/narrative/tool-handlers.ts +0 -528
  162. package/src/narrative/types.ts +0 -9
  163. package/src/narrative/validation.ts +0 -179
  164. package/src/pde/index.ts +0 -34
  165. package/src/pde/mcp-handlers.ts +0 -359
  166. package/src/pde/mcp-tools.ts +0 -201
  167. package/src/pde/session-manager.ts +0 -248
  168. package/src/pde/stc-mapper.ts +0 -298
  169. package/src/pipeline/index.ts +0 -7
  170. package/src/pipeline/template-engine.ts +0 -398
  171. package/src/planning/index.ts +0 -32
  172. package/src/planning/mcp-handlers.ts +0 -369
  173. package/src/planning/mcp-tools.ts +0 -155
  174. package/src/planning/plan-parser.ts +0 -587
  175. package/src/redis.ts +0 -111
  176. package/src/types.ts +0 -281
  177. package/src/version.ts +0 -39
  178. package/test/config.test.mjs +0 -93
  179. package/tsconfig.json +0 -26
@@ -1,186 +0,0 @@
1
- # Prompt Decomposition as Engineering Methodology
2
-
3
- > Academic brief for the CoAiA.js project — Breaking complex prompts into primary/secondary intents, context requirements, and Four Directions action stacks through systematic decomposition.
4
-
5
- ## Abstract
6
-
7
- Complex prompts submitted to large language models frequently contain multiple intents—some explicit, some implied by hedging language or contextual assumptions. When processed holistically, LLMs tend to prioritize salient explicit intents while dropping implicit ones, resulting in incomplete task execution. This paper presents Prompt Decomposition Engineering (PDE) as a systematic methodology for analyzing complex prompts before execution. PDE identifies primary and secondary intents, extracts implicit requirements from hedging language ("maybe," "also consider," "if possible"), maps dependencies between action items, and organizes them into executable Four Directions action stacks. We compare PDE with existing reasoning strategies—Chain-of-Thought (CoT), Tree-of-Thought (ToT), Self-Consistency, and Decomposed Prompting (DecomP)—and argue that PDE operates at a fundamentally different level: it decomposes the *input prompt* rather than the *reasoning process*, serving as a completeness safeguard rather than a reasoning enhancer. The methodology is evaluated in the context of the CoAiA.js PDE engine.
8
-
9
- ## Introduction
10
-
11
- A user submits the following prompt to an AI agent:
12
-
13
- > "Set up the project with TypeScript, add ESLint and Prettier, maybe also configure Husky for pre-commit hooks, and write a basic README. Oh and we'll probably need tests too—Jest should work. Make sure the CI/CD pipeline runs everything."
14
-
15
- This 44-word prompt contains at least seven distinct action items, three implicit dependencies, two hedged requests ("maybe," "probably"), and one underdetermined requirement ("runs everything"). A capable LLM might execute the most salient items (TypeScript setup, ESLint, README) while dropping the hedged ones (Husky, Jest) and underdetermining others (CI/CD scope) [1].
16
-
17
- The fundamental issue is not that LLMs lack capability—it's that complex prompts exceed the scope of single-pass intent extraction. Prompt Decomposition Engineering addresses this by introducing a systematic pre-processing phase that decomposes complex prompts into structured, complete, and dependency-mapped action specifications before execution begins.
18
-
19
- ## Background
20
-
21
- ### Existing Prompt Engineering Strategies
22
-
23
- The prompt engineering landscape has produced several strategies for improving LLM reasoning on complex tasks:
24
-
25
- **Chain-of-Thought (CoT):** Introduced by Wei et al. (2022), CoT prompts models to "think step by step," revealing intermediate reasoning. This improves accuracy on multi-step problems but does not prevent intent loss—the model may reason carefully about a subset of intents while still dropping others [2].
26
-
27
- **Tree-of-Thought (ToT):** Yao et al. (2023) extended CoT to explore multiple reasoning branches simultaneously, evaluating alternative solution paths. ToT improves exploration of solution spaces but addresses reasoning quality, not input completeness—it assumes all intents have been correctly identified [3].
28
-
29
- **Self-Consistency:** Wang et al. (2022) proposed sampling multiple reasoning paths and selecting the most consistent answer. This reduces errors in reasoning but does not address the prior problem of intent extraction from complex inputs [4].
30
-
31
- **Decomposed Prompting (DecomP):** Khot et al. (2022) introduced decomposition of complex questions into sub-questions, each handled by specialized sub-prompts. DecomP is the closest precursor to PDE but operates on reasoning decomposition rather than input prompt decomposition—it assumes the question is well-specified and decomposes the answer strategy [5].
32
-
33
- **Plan-and-Solve (PS):** Wang et al. (2023) proposed devising a plan before executing, then following the plan step-by-step. PS addresses sequencing but not completeness—the plan may omit implicit intents [6].
34
-
35
- ### The Completeness Gap
36
-
37
- All existing strategies share a common assumption: the model correctly identifies all intents in the input prompt. This assumption fails for complex, multi-intent prompts—particularly those containing:
38
-
39
- - **Hedging language:** "maybe," "perhaps," "if possible," "also consider"
40
- - **Embedded conditionals:** "if X then also Y"
41
- - **Implied requirements:** "set up CI/CD" implies test execution, linting, build verification
42
- - **Conversational asides:** "oh and we'll need..." signals an afterthought the model may deprioritize
43
- - **Scope ambiguity:** "make sure everything works" requires decomposition to define "everything"
44
-
45
- PDE addresses this completeness gap by operating on the prompt itself, before any reasoning strategy is applied.
46
-
47
- ## Analysis
48
-
49
- ### The PDE Methodology
50
-
51
- PDE operates in three phases:
52
-
53
- #### Phase 1: Intent Extraction
54
-
55
- The complex prompt is analyzed for:
56
-
57
- **Primary Intents:** Directly stated, unhedged action items.
58
- ```json
59
- [
60
- {"intent": "Set up project with TypeScript", "confidence": "high", "explicit": true},
61
- {"intent": "Add ESLint and Prettier", "confidence": "high", "explicit": true},
62
- {"intent": "Write a basic README", "confidence": "high", "explicit": true}
63
- ]
64
- ```
65
-
66
- **Secondary Intents:** Hedged, implied, or conditionally stated items.
67
- ```json
68
- [
69
- {"intent": "Configure Husky for pre-commit hooks", "confidence": "medium", "marker": "maybe also"},
70
- {"intent": "Set up Jest testing", "confidence": "medium", "marker": "probably need"},
71
- {"intent": "Configure CI/CD pipeline", "confidence": "high", "explicit": true, "underdetermined": true}
72
- ]
73
- ```
74
-
75
- **Implicit Intents:** Requirements not stated but logically entailed.
76
- ```json
77
- [
78
- {"intent": "Create package.json with scripts", "derivedFrom": "TypeScript setup + tooling"},
79
- {"intent": "Create tsconfig.json", "derivedFrom": "TypeScript setup"},
80
- {"intent": "Define CI/CD scope (lint, test, build)", "derivedFrom": "CI/CD + all tools mentioned"}
81
- ]
82
- ```
83
-
84
- #### Phase 2: Dependency Mapping
85
-
86
- Extracted intents are analyzed for dependencies:
87
-
88
- ```
89
- TypeScript setup ← ESLint config (needs tsconfig)
90
- TypeScript setup ← Jest config (needs ts-jest)
91
- ESLint + Prettier ← Husky pre-commit hooks (hooks run lint/format)
92
- All tooling ← CI/CD pipeline (pipeline runs all tools)
93
- All tooling ← README (documents all tools)
94
- ```
95
-
96
- This dependency graph prevents execution ordering errors (e.g., configuring Husky before ESLint exists).
97
-
98
- #### Phase 3: Four Directions Organization
99
-
100
- Extracted and dependency-mapped intents are organized into a Four Directions action stack:
101
-
102
- **East (Vision/Initiation):** Understand the project requirements, establish the desired architecture, define what "done" looks like.
103
-
104
- **South (Analysis/Design):** Decompose into specific, executable tasks. This is where PDE's output resides—the structured decomposition.
105
-
106
- **West (Implementation/Testing):** Execute the tasks in dependency order, verifying each step.
107
-
108
- **North (Integration/Wisdom):** Review the complete result, verify all intents (including secondary and implicit) have been addressed, document the outcome.
109
-
110
- ### Comparison with Existing Strategies
111
-
112
- | Strategy | Operates On | Addresses | Completeness |
113
- |----------|------------|-----------|-------------|
114
- | CoT | Reasoning process | Accuracy | No |
115
- | ToT | Solution exploration | Creativity | No |
116
- | Self-Consistency | Answer validation | Reliability | No |
117
- | DecomP | Question structure | Complexity | Partial |
118
- | Plan-and-Solve | Execution plan | Sequencing | Partial |
119
- | **PDE** | **Input prompt** | **Completeness** | **Yes** |
120
-
121
- PDE is complementary to, not competitive with, existing strategies. A system can first apply PDE to ensure all intents are captured, then apply CoT or ToT to reason about each extracted intent.
122
-
123
- ### Hedging Language as Signal, Not Noise
124
-
125
- A distinctive contribution of PDE is its treatment of hedging language. Traditional NLP treats hedging ("maybe," "perhaps," "if possible") as uncertainty markers to be discounted. PDE treats them as **intent signals with reduced confidence**—the user wants the thing, but is expressing it with social softening or conditional framing.
126
-
127
- When a user says "maybe also configure Husky," they almost certainly want Husky configured—the "maybe" reflects conversational politeness or uncertainty about whether it's the right tool, not genuine indifference to the outcome. PDE captures this as a secondary intent with a confidence annotation, ensuring it is not dropped during execution.
128
-
129
- ### The Decomposition Result Schema
130
-
131
- PDE produces a structured `DecompositionResult` object:
132
-
133
- ```typescript
134
- interface DecompositionResult {
135
- id: string;
136
- timestamp: string;
137
- originalPrompt: string;
138
- primaryIntents: Intent[];
139
- secondaryIntents: Intent[];
140
- implicitIntents: Intent[];
141
- contextRequirements: ContextRequirement[];
142
- dependencies: Dependency[];
143
- fourDirectionsStack: {
144
- east: ActionItem[]; // Vision
145
- south: ActionItem[]; // Analysis
146
- west: ActionItem[]; // Implementation
147
- north: ActionItem[]; // Integration
148
- };
149
- ambiguityFlags: AmbiguityFlag[];
150
- }
151
- ```
152
-
153
- This schema is serialized as JSON and stored in a `.pde/` directory alongside the project, creating a persistent record of prompt decompositions that can be reviewed, edited, and versioned.
154
-
155
- ### PDE as Completeness Safeguard
156
-
157
- The primary value proposition of PDE is not sophistication but **completeness.** In multi-mission agent sessions where a single prompt may contain dozens of intents spanning multiple domains, the risk of intent loss is the primary failure mode. PDE functions as a safeguard against this loss—a systematic check that everything the user asked for has been identified before execution begins.
158
-
159
- This is particularly critical in voice-transcription handoff scenarios, where speech-to-text produces raw verbatim text with conversational hedging, tangential asides, and implicit assumptions that text-based prompts typically refine away.
160
-
161
- ## Implications for CoAiA.js
162
-
163
- PDE is the entry point of the CoAiA.js agent pipeline:
164
-
165
- 1. **Session start decomposition.** Every agent session begins with PDE decomposition of the user's initial prompt, ensuring no intents are lost before work begins.
166
- 2. **Structural tension chart generation.** PDE's output feeds directly into STC creation—primary intents become desired outcomes, current reality is assessed, and action steps are populated from the Four Directions stack.
167
- 3. **MMOT completeness checks.** During evaluation, agents verify that all extracted intents (including secondary and implicit) have been addressed, using PDE's output as the completeness checklist.
168
- 4. **Version-controlled decompositions.** PDE results stored in `.pde/` directories provide audit trails showing exactly how complex prompts were interpreted.
169
- 5. **MCP integration.** The PDE engine is exposed as an MCP tool, enabling any MCP-compliant host to decompose prompts using the same methodology.
170
-
171
- ## Conclusion
172
-
173
- Prompt Decomposition Engineering addresses a fundamental gap in the prompt engineering landscape: the completeness of intent extraction from complex, multi-intent prompts. By operating on the input prompt rather than the reasoning process, PDE complements existing strategies (CoT, ToT, DecomP) while solving a distinct problem. The methodology's systematic extraction of primary, secondary, and implicit intents—combined with dependency mapping and Four Directions organization—provides the completeness safeguard that complex agent sessions require.
174
-
175
- ## References
176
-
177
- 1. LearnPrompting. (2024). "Advanced Decomposition Techniques for Improved Prompting in LLMs." https://learnprompting.org/docs/advanced/decomposition/introduction
178
- 2. Wei, J., et al. (2022). "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models." *NeurIPS 2022*.
179
- 3. Yao, S., et al. (2023). "Tree of Thoughts: Deliberate Problem Solving with Large Language Models." *NeurIPS 2023*.
180
- 4. Wang, X., et al. (2022). "Self-Consistency Improves Chain of Thought Reasoning in Language Models." *ICLR 2023*.
181
- 5. Khot, T., et al. (2022). "Decomposed Prompting: A Modular Approach for Solving Complex Tasks." *ICLR 2023*.
182
- 6. Wang, L., et al. (2023). "Plan-and-Solve Prompting: Improving Zero-Shot Chain-of-Thought Reasoning." *ACL 2023*.
183
- 7. Oxen.ai. (2024). "The Prompt Report Part 2: Plan and Solve, Tree of Thought, and Decomposition Prompting." https://ghost.oxen.ai/the-prompt-report-part-2-thought-generation-tree-of-thought-and-decomposition-prompting/
184
- 8. CalmOps. (2024). "Prompt Engineering Patterns: CoT, ReAct, and ToT." https://calmops.com/ai/prompt-engineering-patterns-cot-react-tot/
185
- 9. Exploratio Journal. (2024). "Zooming-in On Prompting: A Comparative Study." https://exploratiojournal.com/zooming-in-on-prompting/
186
- 10. Coupler.io. (2024). "Advanced Prompting Techniques for Complex AI Reasoning." https://blog.coupler.io/advanced-prompting-techniques/
@@ -1,134 +0,0 @@
1
- # Structural Tension in AI Agents: Robert Fritz's Methodology Applied to Autonomous Goal Management
2
-
3
- > Academic brief for the CoAiA.js project — Structural tension charts as computational data structures for tracking desired outcomes versus current reality in autonomous AI agent systems.
4
-
5
- ## Abstract
6
-
7
- Autonomous AI agents face a fundamental challenge: maintaining coherent progress toward goals while continuously adapting to evolving environments. This paper examines how Robert Fritz's structural tension methodology—originally developed for human creative processes—can be formalized as a computational framework for AI agent goal management. We define structural tension charts (STCs) as first-class data structures encoding the gap between a desired outcome and an assessed current reality, with tension resolution driving agent behavior. Unlike traditional goal-stack or utility-maximization approaches, structural tension provides a creative orientation that sustains forward momentum without the oscillatory patterns characteristic of problem-solving architectures. We analyze the formal properties of STCs, their implementation as JSONL-backed state machines, and their implications for agent autonomy, self-correction, and telescoping goal decomposition. The framework is evaluated in the context of CoAiA.js, a JavaScript runtime for structurally-tensioned AI agents.
8
-
9
- ## Introduction
10
-
11
- The design of AI agent goal management systems has historically drawn from planning literature (STRIPS, HTN), reinforcement learning (reward maximization), and behavioral architectures (subsumption, BDI). While these approaches have proven effective in constrained domains, they share a common structural limitation: they are fundamentally problem-solving architectures, oriented toward the elimination of undesirable states rather than the creation of desired ones.
12
-
13
- Robert Fritz, in *The Path of Least Resistance* (1989) and *Creating* (1991), identified a critical distinction between two orientations toward action. Problem-solving orientation generates energy by moving away from what is unwanted; creative orientation generates energy by moving toward what is desired. Fritz demonstrated that problem-solving architectures produce oscillatory dynamics—as the problem diminishes, so does motivation, leading to cyclical regression. Creative orientation, by contrast, produces advancing dynamics through structural tension: the sustained gap between a clearly articulated desired outcome and an honestly assessed current reality [1].
14
-
15
- This paper formalizes structural tension as a computational construct for AI agent systems. We argue that encoding desired outcomes and current reality as co-evolving data structures—with the tension between them as the primary driver of agent behavior—produces agents with superior goal coherence, self-correction capabilities, and resistance to the oscillatory patterns that plague reactive architectures.
16
-
17
- ## Background
18
-
19
- ### Fritz's Structural Tension Model
20
-
21
- The structural tension model rests on three axioms:
22
-
23
- 1. **Tension seeks resolution.** A system with a gap between desired outcome and current reality will tend toward resolution of that gap, following the path of least resistance.
24
- 2. **The path of least resistance is determined by underlying structure.** The arrangement of elements in a system determines how tension resolves—whether through advancement toward the desired outcome or oscillation between states.
25
- 3. **Creative orientation produces advancing structures.** When the desired outcome is held constant and current reality is honestly assessed, tension resolves through advancement. When the problem is the primary reference point, tension resolves through oscillation [1][2].
26
-
27
- Fritz's methodology requires practitioners to: (a) clearly articulate what they want to create, (b) honestly assess current reality relative to that vision, and (c) hold both simultaneously, allowing the structural tension to drive action [3].
28
-
29
- ### Existing Agent Goal Architectures
30
-
31
- Traditional agent architectures encode goals in several ways:
32
-
33
- - **Goal stacks** (STRIPS/PDDL): Goals as predicate conditions to satisfy. No notion of ongoing tension; goals are binary (achieved/not achieved).
34
- - **Utility functions** (RL/MDPs): Goals as reward signals to maximize. Susceptible to reward hacking and lacks semantic richness.
35
- - **BDI architectures**: Beliefs-Desires-Intentions model maintains goal hierarchies but lacks the structural tension dynamic that prevents oscillation.
36
- - **Behavior trees**: Reactive architectures that respond to conditions without maintaining creative tension toward outcomes [4].
37
-
38
- None of these architectures encode the dual-reference-point structure (desired outcome + current reality) that Fritz identifies as essential for sustained creative advancement.
39
-
40
- ## Analysis
41
-
42
- ### Structural Tension Charts as Data Structures
43
-
44
- We define a Structural Tension Chart (STC) as a tuple:
45
-
46
- ```
47
- STC = (D, R, A[], T, Δ)
48
- ```
49
-
50
- Where:
51
- - **D** (Desired Outcome): A natural-language description of the target state, held constant unless explicitly revised.
52
- - **R** (Current Reality): A timestamped, append-only log of observations about the present state. Critically, R must be an honest assessment—not a readiness statement or aspiration.
53
- - **A[]** (Action Steps): An ordered set of intermediate goals, each of which is itself a telescoped STC.
54
- - **T** (Tension): The computed gap between D and R, which drives agent decision-making.
55
- - **Δ** (Delta History): A temporal record of reality updates, enabling the agent to assess whether it is advancing or oscillating.
56
-
57
- The key innovation is that **tension is not a problem to solve but a creative force to harness**. The agent does not minimize a loss function; it moves toward a desired creation while continuously updating its understanding of reality.
58
-
59
- ### Telescoping: Recursive Goal Decomposition
60
-
61
- A critical feature of structural tension methodology is telescoping—the ability to decompose any action step into its own full STC. This creates a recursive hierarchy:
62
-
63
- ```
64
- Master STC
65
- ├── Action Step 1 → Telescoped STC₁
66
- │ ├── Sub-action 1a → Telescoped STC₁ₐ
67
- │ └── Sub-action 1b → Telescoped STC₁ᵦ
68
- ├── Action Step 2 → Telescoped STC₂
69
- └── Action Step 3 → Telescoped STC₃
70
- ```
71
-
72
- Each telescoped STC maintains its own desired outcome, current reality, and tension. This structure enables agents to work at multiple levels of abstraction simultaneously, focusing on immediate sub-tasks while maintaining alignment with higher-level creative intent.
73
-
74
- ### Preventing Oscillation: The Structural Advantage
75
-
76
- Fritz observed that problem-solving systems oscillate because their energy source (the problem) diminishes as progress is made. In computational terms, a reward-minimization agent that reduces error from 0.8 to 0.2 experiences diminishing gradient—the "problem" is mostly "solved," and momentum collapses.
77
-
78
- Structural tension charts prevent this because:
79
-
80
- 1. **The desired outcome remains constant.** The vision does not diminish as reality improves.
81
- 2. **Current reality is continuously re-assessed.** New observations may reveal previously unknown gaps, maintaining or even increasing tension.
82
- 3. **Completion is binary and explicit.** An action step is marked complete through deliberate assessment (the Managerial Moment of Truth), not through gradient convergence.
83
-
84
- ### Implementation: JSONL-Backed State Machines
85
-
86
- In the CoAiA.js implementation, STCs are stored as append-only JSONL (JSON Lines) records:
87
-
88
- ```jsonl
89
- {"type":"chart","id":"chart_001","desiredOutcome":"Production-ready MCP server","currentReality":"Prototype exists with 3 tools; no tests, no error handling","createdAt":"2026-03-10T14:00:00Z"}
90
- {"type":"action","chartId":"chart_001","name":"chart_001_action_1","title":"Implement error handling","currentReality":"No try-catch patterns; errors crash the process"}
91
- {"type":"reality_update","chartId":"chart_001","observation":"Added error boundaries to tool dispatch; 2 of 5 tools now handle errors gracefully","timestamp":"2026-03-10T16:30:00Z"}
92
- {"type":"completion","actionName":"chart_001_action_1","timestamp":"2026-03-10T18:00:00Z"}
93
- ```
94
-
95
- The append-only format ensures that no historical state is lost—every observation, update, and completion is preserved. This enables temporal analysis of tension dynamics: is the agent advancing, oscillating, or stalled?
96
-
97
- ### Tension as Agent Decision Driver
98
-
99
- Rather than selecting actions through utility maximization or plan execution, a structurally-tensioned agent operates through the following cycle:
100
-
101
- 1. **Assess tension:** Compare desired outcome against current reality across all active STCs.
102
- 2. **Select highest-tension chart:** The STC with the greatest gap between D and R receives attention.
103
- 3. **Identify next action:** Within the selected chart, find the next incomplete action step.
104
- 4. **Execute and observe:** Perform the action and update current reality with honest observations.
105
- 5. **Evaluate via MMOT:** Apply the Managerial Moment of Truth to assess whether the action advanced the chart or revealed new gaps.
106
-
107
- This cycle naturally produces depth-first progress on high-priority goals while enabling context switching when new information shifts the tension landscape.
108
-
109
- ## Implications for CoAiA.js
110
-
111
- CoAiA.js implements structural tension charts as its primary goal management primitive. The implications are:
112
-
113
- 1. **Agent sessions are organized around STCs**, not task lists. Every agent session begins with chart creation—articulating a desired outcome and honestly assessing current reality.
114
- 2. **Progress is measured by reality advancement**, not task completion counts. An agent that completes 10 tasks but fails to advance current reality toward the desired outcome has not made meaningful progress.
115
- 3. **Telescoping enables multi-scale operation.** Agents can decompose complex goals into nested STCs, each maintaining its own tension dynamics, while the master chart provides coherence.
116
- 4. **JSONL storage provides full auditability.** Every decision, observation, and completion is recorded, enabling post-hoc analysis of agent behavior and tension dynamics.
117
- 5. **The MMOT cycle provides self-correction.** Agents can detect oscillation by analyzing their Δ history and adjust their approach when advancement stalls.
118
-
119
- ## Conclusion
120
-
121
- Structural tension charts offer a fundamentally different paradigm for AI agent goal management—one rooted in creative orientation rather than problem-solving. By encoding the gap between desired outcomes and current reality as a first-class data structure, and by driving agent behavior through tension resolution rather than reward maximization, we obtain agents that advance coherently toward creative goals without the oscillatory dynamics that plague reactive architectures. The formalization presented here provides a foundation for building AI systems that create rather than merely optimize.
122
-
123
- ## References
124
-
125
- 1. Fritz, R. (1989). *The Path of Least Resistance: Learning to Become the Creative Force in Your Own Life*. Fawcett Columbine.
126
- 2. Fritz, R. (1999). *The Path of Least Resistance for Managers*. Berrett-Koehler Publishers.
127
- 3. Foss, L. "Structural Tension Model." https://www.larafoss.com/structural-tension
128
- 4. Wooldridge, M. (2009). *An Introduction to MultiAgent Systems*. 2nd ed. Wiley.
129
- 5. Fritz, R. "Tension Seeks Resolution." Robert Fritz Inc. https://www.robertfritz.com/wp/principles/tension-seeks-resolution/
130
- 6. Think-2-Thrive. (2024). "Leading with Creative Tension." https://think-2-thrive.com/2024/12/02/blog-55-leading-with-creative-tension/
131
- 7. Thwink.org. "Structural Tension." https://www.thwink.org/soft/info/process/structural/StructuralTension.html
132
- 8. Senge, P. (1990). *The Fifth Discipline: The Art & Practice of the Learning Organization*. Doubleday.
133
- 9. Rao, A. S., & Georgeff, M. P. (1995). "BDI Agents: From Theory to Practice." *Proceedings of the First International Conference on Multi-Agent Systems (ICMAS-95)*.
134
- 10. Fritz, R., & Bodaken, B. (2006). *The Managerial Moment of Truth*. Free Press.
@@ -1,170 +0,0 @@
1
- # Literature Review: MCP Protocol Design Decisions
2
-
3
- > Literature review for the CoAiA.js project — Comparative analysis of MCP's design choices against gRPC, REST, and GraphQL for AI agent tool invocation.
4
-
5
- ## Abstract
6
-
7
- The Model Context Protocol (MCP), introduced by Anthropic in late 2024, makes specific design choices that distinguish it from established communication protocols: JSON-RPC 2.0 over Protocol Buffers, dual-transport (stdio/HTTP) over unified transport, dynamic tool discovery over static contracts, and human-in-the-loop approval over autonomous execution. This literature review examines these design decisions in the context of the broader protocol landscape—comparing MCP with gRPC (high-performance RPC), REST (ubiquitous web APIs), and GraphQL (flexible data querying)—and evaluates whether MCP's trade-offs are appropriate for its target domain: AI agent tool invocation. We review protocol design literature, benchmark data, and emerging production experience to assess MCP's architectural fitness for the next generation of AI agent systems.
8
-
9
- ## Introduction
10
-
11
- Protocol design for AI agent systems faces a unique set of requirements not fully addressed by existing protocols. Traditional protocols were designed for human-initiated, deterministic interactions: a client knows what it wants, constructs a request, and expects a predictable response. AI agent tool invocation differs fundamentally: the agent may not know which tools are available until runtime, the semantics of tool descriptions must be LLM-comprehensible, tool invocation may require human approval, and sessions may maintain state across multiple tool calls [1][2].
12
-
13
- MCP was designed from first principles for this new interaction pattern. This review examines whether its design decisions are well-justified by comparing each choice against alternatives from the protocol design literature.
14
-
15
- ## Review
16
-
17
- ### Design Decision 1: JSON-RPC 2.0 vs. Protocol Buffers
18
-
19
- **MCP's Choice:** All communication uses JSON-RPC 2.0—a lightweight, text-based RPC protocol where requests and responses are JSON objects [3].
20
-
21
- **Alternative: Protocol Buffers (gRPC).** gRPC uses Protocol Buffers for binary serialization, achieving significantly lower payload sizes and faster parsing. Benchmarks consistently show gRPC outperforming JSON-based protocols by 5-10x in throughput and 2-5x in latency for high-volume workloads [4][5].
22
-
23
- **Analysis:**
24
-
25
- The MCP team's choice of JSON-RPC prioritizes three properties over raw performance:
26
-
27
- 1. **Debuggability.** JSON messages are human-readable, enabling developers to inspect traffic with standard text tools. Protocol Buffers require specialized tools for inspection.
28
-
29
- 2. **Ecosystem breadth.** JSON parsing is native in every programming language. Protocol Buffer support requires additional libraries and code generation steps.
30
-
31
- 3. **LLM compatibility.** LLMs naturally produce and consume JSON. Protocol Buffers' binary format would require an additional serialization layer between the LLM and the protocol.
32
-
33
- **Literature Support:** The Language Server Protocol (LSP), MCP's direct architectural predecessor, made the identical choice—JSON-RPC 2.0 over binary protocols—for the same reasons. LSP's success across dozens of language implementations validates this trade-off for developer-facing protocols [6].
34
-
35
- **Performance Impact:** For AI agent workloads, LLM inference dominates latency (typically 1-30 seconds per generation). The difference between JSON-RPC and Protocol Buffers (~1-5ms per message) is negligible in this context. The trade-off is justified.
36
-
37
- ### Design Decision 2: Dual Transport (Stdio + HTTP)
38
-
39
- **MCP's Choice:** Two transport modes: stdio for local (same-machine) integration, HTTP with Server-Sent Events for distributed deployment [3].
40
-
41
- **Alternatives:**
42
- - **gRPC:** HTTP/2 only (with bidirectional streaming)
43
- - **REST:** HTTP/1.1 or HTTP/2 (stateless)
44
- - **GraphQL:** HTTP (typically POST, with WebSocket for subscriptions)
45
-
46
- **Analysis:**
47
-
48
- MCP's dual-transport design addresses the fundamental deployment dichotomy in AI agent systems:
49
-
50
- **Local Development (Stdio):** During development, agents and tools run on the same machine. Stdio transport provides:
51
- - Zero network configuration
52
- - Process lifecycle management (parent starts/stops child)
53
- - Inherent security (no network exposure)
54
- - No port conflicts or firewall issues
55
-
56
- **Production Deployment (HTTP):** In production, tools may run as shared services, cloud functions, or on different machines. HTTP transport provides:
57
- - Network accessibility
58
- - Authentication and authorization integration
59
- - Load balancing and scaling
60
- - Server-Sent Events for real-time notifications
61
-
62
- **Literature Support:** The stdio + TCP dual-transport pattern originated with LSP and has been validated across thousands of IDE integrations. Research on developer experience shows that zero-config local development significantly impacts adoption—developers who can try a tool immediately are more likely to integrate it permanently [7].
63
-
64
- **Comparison with Alternatives:** gRPC's HTTP/2-only transport creates friction for local development (requires server process, port allocation). REST's stateless model requires workarounds for maintaining session context. GraphQL's single-endpoint design is elegant but doesn't naturally support the process-lifecycle semantics that stdio provides.
65
-
66
- ### Design Decision 3: Dynamic Tool Discovery vs. Static Contracts
67
-
68
- **MCP's Choice:** Clients discover available tools at runtime through `tools/list` requests. Tool schemas are self-describing JSON objects with natural-language descriptions [3][8].
69
-
70
- **Alternatives:**
71
- - **gRPC:** Static `.proto` files define services at compile time. Reflection is available but not standard practice.
72
- - **REST:** OpenAPI/Swagger specifications describe endpoints statically. Runtime discovery requires additional infrastructure.
73
- - **GraphQL:** Schema introspection is native, but schemas are typically static and manually authored.
74
-
75
- **Analysis:**
76
-
77
- Dynamic tool discovery is MCP's most innovative design decision and the one most clearly motivated by AI-specific requirements:
78
-
79
- 1. **LLM Tool Selection.** LLMs select tools based on natural-language descriptions. MCP's tool schemas include human-readable `description` fields that LLMs use for semantic matching. Static contracts lack this semantic layer.
80
-
81
- 2. **Composable Tool Sets.** An agent may connect to different MCP servers depending on the task—a code-editing server for development tasks, a database server for data tasks. Dynamic discovery enables this modular composition without pre-configuration.
82
-
83
- 3. **Graceful Degradation.** If a server is unavailable, the agent operates with reduced capabilities rather than failing. Static contracts make unavailable tools compile-time or configuration errors.
84
-
85
- **Literature Support:** Service discovery patterns in microservice architectures (Consul, Eureka, Kubernetes DNS) demonstrate the value of runtime discovery for dynamic systems. The research on self-describing services in semantic web literature directly prefigures MCP's approach [9].
86
-
87
- **Trade-off:** Dynamic discovery introduces the risk of inconsistent tool sets across invocations—a tool available in one call may not be available in the next. MCP mitigates this through capability negotiation at session initialization.
88
-
89
- ### Design Decision 4: Human-in-the-Loop Approval Gates
90
-
91
- **MCP's Choice:** The specification explicitly supports human approval gates for sensitive tool invocations, with the host application presenting confirmation dialogs [3][10].
92
-
93
- **Alternatives:**
94
- - **gRPC:** No built-in approval mechanism; security is handled at the transport/middleware level.
95
- - **REST:** Authentication/authorization at the endpoint level; no per-request human approval.
96
- - **GraphQL:** Permission checking in resolvers; no standard approval UX.
97
-
98
- **Analysis:**
99
-
100
- MCP's approval gate design reflects the unique risk profile of AI agent tool invocation:
101
-
102
- 1. **Non-deterministic requests.** Unlike human-initiated API calls, AI-generated tool invocations may be unexpected, incorrect, or dangerous. A human checkpoint prevents autonomous execution of high-impact operations.
103
-
104
- 2. **Progressive trust.** The approval mechanism enables a trust gradient: agents begin with full approval requirements, which can be relaxed for trusted operations as confidence grows.
105
-
106
- 3. **Creative orientation alignment.** In the structural tension framework, human approval ensures that agent actions align with the human's desired outcome, not just the agent's interpretation of it.
107
-
108
- **Literature Support:** Research on human-AI teaming demonstrates that appropriate human checkpoints improve both safety and user trust. The "HITL" (human-in-the-loop) pattern is established best practice in safety-critical AI applications [11].
109
-
110
- ### Design Decision 5: Three Primitives (Tools, Resources, Prompts)
111
-
112
- **MCP's Choice:** Three semantic primitives cover the full range of agent-tool interactions [3]:
113
- - **Tools:** Executable functions with side effects
114
- - **Resources:** Read-only data sources
115
- - **Prompts:** Instruction templates
116
-
117
- **Comparison with Traditional APIs:**
118
- - **REST:** Uses HTTP verbs (GET, POST, PUT, DELETE) as primitives—action-oriented but lacking semantic richness
119
- - **gRPC:** Uses service methods as primitives—typed but not self-describing
120
- - **GraphQL:** Uses queries, mutations, and subscriptions—closest to MCP's three-primitive model
121
-
122
- **Analysis:**
123
-
124
- MCP's three primitives map cleanly to the three modes of agent-tool interaction:
125
- - "Do something" → Tool
126
- - "Tell me something" → Resource
127
- - "Guide my behavior" → Prompt
128
-
129
- GraphQL's query/mutation/subscription model is structurally similar but lacks the AI-specific semantics—particularly the "prompt" primitive, which has no analog in traditional protocols.
130
-
131
- ## Synthesis
132
-
133
- MCP's design decisions collectively optimize for a specific user: an LLM-powered agent that needs to discover, understand, and invoke tools in a human-supervised context. Each decision trades performance for accessibility, static safety for dynamic flexibility, and autonomous execution for human oversight.
134
-
135
- The trade-offs are well-justified for the target domain:
136
-
137
- | Decision | Trade-off | Justification |
138
- |----------|-----------|---------------|
139
- | JSON-RPC | Performance for debuggability | LLM inference dominates latency |
140
- | Dual transport | Complexity for deployment flexibility | Addresses local vs. distributed dichotomy |
141
- | Dynamic discovery | Consistency for composability | LLM tool selection requires runtime semantics |
142
- | Approval gates | Autonomy for safety | Non-deterministic requests require human checkpoints |
143
- | Three primitives | Simplicity for semantic clarity | Maps cleanly to agent interaction modes |
144
-
145
- ## Implications for CoAiA.js
146
-
147
- 1. **MCP as default protocol.** CoAiA.js adopts MCP for all external tool interactions, leveraging its AI-native design.
148
- 2. **Stdio for development.** Local development uses stdio transport, enabling zero-config agent setup.
149
- 3. **HTTP for production.** Production deployments use HTTP transport with SSE for real-time notifications.
150
- 4. **STC operations as MCP tools.** Structural tension chart operations are exposed through MCP, enabling cross-framework access.
151
- 5. **Approval gates for MMOT.** Human approval is integrated with the MMOT cycle—agents propose corrections, humans approve execution.
152
-
153
- ## Conclusion
154
-
155
- MCP's protocol design decisions reflect a clear understanding of AI agent requirements that differ fundamentally from traditional client-server interactions. By prioritizing debuggability, dynamic discovery, and human oversight over raw performance and static contracts, MCP establishes a protocol layer that is fit for purpose in the emerging AI agent ecosystem. The comparison with gRPC, REST, and GraphQL reveals not that MCP is "better" in absolute terms, but that it is better *for its intended domain*—a distinction that validates Anthropic's decision to create a new protocol rather than adapting an existing one.
156
-
157
- ## References
158
-
159
- 1. Anthropic. (2024). "Introducing the Model Context Protocol." https://www.anthropic.com/news/model-context-protocol
160
- 2. CloudCusp. (2025). "MCP and gRPC: Why MCP Beats gRPC for AI." https://cloudcusp.com/blogs/mcp-and-grpc-why-mcp-beats-grpc-in-ai/
161
- 3. Model Context Protocol Specification. (2025). https://modelcontextprotocol.io/specification/2025-03-26
162
- 4. SmartDev. (2025). "AI-Powered APIs: REST vs GraphQL vs gRPC Performance." https://smartdev.com/ai-powered-apis-grpc-vs-rest-vs-graphql/
163
- 5. AI Fire. (2025). "MCP vs gRPC: The Future of AI-Native Agent Connectivity." https://www.aifire.co/p/mcp-vs-grpc-the-future-of-ai-native-agent-connectivity
164
- 6. Microsoft. "Language Server Protocol Specification." https://microsoft.github.io/language-server-protocol/
165
- 7. AIBuilders Academy. (2025). "MCP vs gRPC: How AI Agents Connect to Tools." https://aibuilders.academy/mcp-vs-grpc/
166
- 8. OpenReplay. (2025). "MCP vs REST vs GraphQL: How LLM-First APIs Are Different." https://blog.openreplay.com/mcp-rest-graphql-llm-first-apis/
167
- 9. DEV Community. (2025). "MCP vs Traditional APIs." https://dev.to/sreeni5018/mcp-model-context-protocol-vs-traditional-apis-rest-soap-graphql-grpc-the-future-of-api-pi7
168
- 10. Glama. (2025). "Why AI Agents Need a New Protocol." https://glama.ai/blog/2025-06-06-mcp-vs-api
169
- 11. Reconfigured. (2025). "MCP Guide: Understanding the Protocol Powering the AI Agent Ecosystem." https://reconfigured.io/blog/mcp-guide-understanding-ai-agent-protocol
170
- 12. Geeky Gadgets. (2025). "MCP vs gRPC: Comparing AI Protocols." https://www.geeky-gadgets.com/mcp-vs-grpc-ai-protocols/