coaiajs 0.1.0
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/CLAUDE.md +56 -0
- package/KINSHIP.md +63 -0
- package/README.md +148 -0
- package/articles/academic/creative-orientation-vs-problem-solving.md +177 -0
- package/articles/academic/jsonl-knowledge-graphs-agent-memory.md +142 -0
- package/articles/academic/langfuse-observability-llm-pipelines.md +144 -0
- package/articles/academic/medicine-wheel-software-architecture.md +163 -0
- package/articles/academic/mmot-autonomous-agents.md +156 -0
- package/articles/academic/model-context-protocol-interagent.md +161 -0
- package/articles/academic/pde-prompt-decomposition.md +186 -0
- package/articles/academic/structural-tension-in-ai-agents.md +134 -0
- package/articles/reviews/mcp-protocol-design-review.md +170 -0
- package/articles/reviews/observability-ai-systems-review.md +176 -0
- package/articles/reviews/prompt-engineering-decomposition-review.md +184 -0
- package/articles/surveys/agent-orchestration-survey.md +186 -0
- package/articles/surveys/knowledge-graph-storage-survey.md +204 -0
- package/articles/surveys/structural-tension-methodology-survey.md +154 -0
- package/articles/technical/aws-sdk-v3-polly.md +270 -0
- package/articles/technical/commander-cli-framework.md +262 -0
- package/articles/technical/dotenv-config-patterns.md +360 -0
- package/articles/technical/ioredis-vs-redis.md +142 -0
- package/articles/technical/langfuse-js-sdk-vs-rest.md +191 -0
- package/articles/technical/mcp-sdk-typescript.md +291 -0
- package/articles/technical/octokit-github-api.md +293 -0
- package/articles/technical/openai-sdk-modern.md +231 -0
- package/articles/technical/yaml-parsing-node.md +266 -0
- package/articles/technical/zod-runtime-validation.md +212 -0
- package/dist/mcp/config.d.ts +14 -0
- package/dist/mcp/config.js +185 -0
- package/dist/mcp/server.d.ts +3 -0
- package/dist/mcp/server.js +324 -0
- package/dist/mcp/tools/coaiapy-tools.d.ts +8 -0
- package/dist/mcp/tools/coaiapy-tools.js +326 -0
- package/dist/mcp/tools/index.d.ts +3 -0
- package/dist/mcp/tools/index.js +3 -0
- package/dist/src/audio.d.ts +12 -0
- package/dist/src/audio.js +57 -0
- package/dist/src/cli-helpers.d.ts +9 -0
- package/dist/src/cli-helpers.js +78 -0
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.js +1086 -0
- package/dist/src/config.d.ts +15 -0
- package/dist/src/config.js +145 -0
- package/dist/src/environment.d.ts +44 -0
- package/dist/src/environment.js +146 -0
- package/dist/src/github.d.ts +47 -0
- package/dist/src/github.js +79 -0
- package/dist/src/langfuse/client.d.ts +30 -0
- package/dist/src/langfuse/client.js +75 -0
- package/dist/src/langfuse/comments.d.ts +16 -0
- package/dist/src/langfuse/comments.js +36 -0
- package/dist/src/langfuse/datasets.d.ts +19 -0
- package/dist/src/langfuse/datasets.js +140 -0
- package/dist/src/langfuse/index.d.ts +13 -0
- package/dist/src/langfuse/index.js +10 -0
- package/dist/src/langfuse/media.d.ts +11 -0
- package/dist/src/langfuse/media.js +167 -0
- package/dist/src/langfuse/observations.d.ts +18 -0
- package/dist/src/langfuse/observations.js +113 -0
- package/dist/src/langfuse/prompts.d.ts +14 -0
- package/dist/src/langfuse/prompts.js +127 -0
- package/dist/src/langfuse/scores.d.ts +54 -0
- package/dist/src/langfuse/scores.js +366 -0
- package/dist/src/langfuse/traces.d.ts +29 -0
- package/dist/src/langfuse/traces.js +225 -0
- package/dist/src/llm.d.ts +23 -0
- package/dist/src/llm.js +76 -0
- package/dist/src/narrative/graph-manager.d.ts +106 -0
- package/dist/src/narrative/graph-manager.js +915 -0
- package/dist/src/narrative/index.d.ts +9 -0
- package/dist/src/narrative/index.js +7 -0
- package/dist/src/narrative/markdown-export.d.ts +21 -0
- package/dist/src/narrative/markdown-export.js +383 -0
- package/dist/src/narrative/tool-definitions.d.ts +21 -0
- package/dist/src/narrative/tool-definitions.js +588 -0
- package/dist/src/narrative/tool-handlers.d.ts +11 -0
- package/dist/src/narrative/tool-handlers.js +462 -0
- package/dist/src/narrative/types.d.ts +2 -0
- package/dist/src/narrative/types.js +2 -0
- package/dist/src/narrative/validation.d.ts +29 -0
- package/dist/src/narrative/validation.js +144 -0
- package/dist/src/pde/index.d.ts +8 -0
- package/dist/src/pde/index.js +8 -0
- package/dist/src/pde/mcp-handlers.d.ts +7 -0
- package/dist/src/pde/mcp-handlers.js +300 -0
- package/dist/src/pde/mcp-tools.d.ts +15 -0
- package/dist/src/pde/mcp-tools.js +191 -0
- package/dist/src/pde/session-manager.d.ts +32 -0
- package/dist/src/pde/session-manager.js +205 -0
- package/dist/src/pde/stc-mapper.d.ts +26 -0
- package/dist/src/pde/stc-mapper.js +234 -0
- package/dist/src/pipeline/index.d.ts +2 -0
- package/dist/src/pipeline/index.js +3 -0
- package/dist/src/pipeline/template-engine.d.ts +20 -0
- package/dist/src/pipeline/template-engine.js +361 -0
- package/dist/src/planning/index.d.ts +7 -0
- package/dist/src/planning/index.js +7 -0
- package/dist/src/planning/mcp-handlers.d.ts +7 -0
- package/dist/src/planning/mcp-handlers.js +310 -0
- package/dist/src/planning/mcp-tools.d.ts +15 -0
- package/dist/src/planning/mcp-tools.js +145 -0
- package/dist/src/planning/plan-parser.d.ts +35 -0
- package/dist/src/planning/plan-parser.js +506 -0
- package/dist/src/redis.d.ts +21 -0
- package/dist/src/redis.js +78 -0
- package/dist/src/types.d.ts +244 -0
- package/dist/src/types.js +8 -0
- package/mcp/config.ts +196 -0
- package/mcp/server.ts +402 -0
- package/mcp/tools/coaiapy-tools.ts +364 -0
- package/mcp/tools/index.ts +4 -0
- package/package.json +52 -0
- package/rispecs/00-coaiajs-platform.spec.md +102 -0
- package/rispecs/01-core-config.spec.md +89 -0
- package/rispecs/02-redis-module.spec.md +62 -0
- package/rispecs/03-langfuse-module.spec.md +101 -0
- package/rispecs/04-narrative-engine.spec.md +185 -0
- package/rispecs/05-pde-engine.spec.md +112 -0
- package/rispecs/06-planning-engine.spec.md +128 -0
- package/rispecs/07-pipeline-templates.spec.md +97 -0
- package/rispecs/08-cli-interface.spec.md +134 -0
- package/rispecs/09-mcp-server.spec.md +140 -0
- package/rispecs/10-audio-module.spec.md +63 -0
- package/rispecs/KINSHIP.md +56 -0
- package/rispecs/README.md +100 -0
- package/src/audio.ts +76 -0
- package/src/cli-helpers.ts +86 -0
- package/src/cli.ts +1223 -0
- package/src/config.ts +172 -0
- package/src/environment.ts +171 -0
- package/src/github.ts +143 -0
- package/src/langfuse/client.ts +105 -0
- package/src/langfuse/comments.ts +52 -0
- package/src/langfuse/datasets.ts +178 -0
- package/src/langfuse/index.ts +33 -0
- package/src/langfuse/media.ts +193 -0
- package/src/langfuse/observations.ts +131 -0
- package/src/langfuse/prompts.ts +157 -0
- package/src/langfuse/scores.ts +456 -0
- package/src/langfuse/traces.ts +276 -0
- package/src/llm.ts +106 -0
- package/src/narrative/graph-manager.ts +1358 -0
- package/src/narrative/index.ts +32 -0
- package/src/narrative/markdown-export.ts +535 -0
- package/src/narrative/tool-definitions.ts +635 -0
- package/src/narrative/tool-handlers.ts +528 -0
- package/src/narrative/types.ts +9 -0
- package/src/narrative/validation.ts +179 -0
- package/src/pde/index.ts +8 -0
- package/src/pde/mcp-handlers.ts +359 -0
- package/src/pde/mcp-tools.ts +201 -0
- package/src/pde/session-manager.ts +248 -0
- package/src/pde/stc-mapper.ts +298 -0
- package/src/pipeline/index.ts +7 -0
- package/src/pipeline/template-engine.ts +398 -0
- package/src/planning/index.ts +13 -0
- package/src/planning/mcp-handlers.ts +369 -0
- package/src/planning/mcp-tools.ts +155 -0
- package/src/planning/plan-parser.ts +587 -0
- package/src/redis.ts +97 -0
- package/src/types.ts +280 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,170 @@
|
|
|
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/
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# Literature Review: Observability in AI Systems
|
|
2
|
+
|
|
3
|
+
> Literature review for the CoAiA.js project — OpenTelemetry for LLMs, Langfuse, LangSmith, and Weights & Biases examined through the trace/span/generation model for AI application monitoring.
|
|
4
|
+
|
|
5
|
+
## Abstract
|
|
6
|
+
|
|
7
|
+
Observability for AI systems—particularly LLM-powered applications—has evolved rapidly from ad-hoc logging to structured tracing frameworks that capture the full lifecycle of model interactions. This literature review examines the current state of AI observability through four lenses: OpenTelemetry as the emerging standard for vendor-neutral instrumentation, Langfuse as the leading open-source LLM observability platform, LangSmith as the LangChain-native monitoring solution, and Weights & Biases (W&B Weave) as the experiment-tracking platform extending into production monitoring. We analyze the convergence on a trace/span/generation data model, evaluate each platform's approach to evaluation and scoring, and identify the gap that structural tension methodology fills: transforming observability from a problem-detection tool into a creative advancement instrument.
|
|
8
|
+
|
|
9
|
+
## Introduction
|
|
10
|
+
|
|
11
|
+
Traditional software observability rests on three pillars: logs (event records), metrics (aggregated measurements), and traces (request-scoped execution paths). These pillars, standardized through OpenTelemetry, have proven sufficient for deterministic systems where identical inputs produce identical outputs and where "correct behavior" is well-defined [1][2].
|
|
12
|
+
|
|
13
|
+
LLM-powered applications violate both assumptions. Identical prompts can produce different outputs across invocations (non-determinism), and "correct behavior" is often subjective—dependent on context, user intent, and quality standards that resist formal specification. This fundamental shift requires observability approaches that capture not just operational health but **semantic quality**: what was generated, whether it was helpful, and how it compares to desired standards [3].
|
|
14
|
+
|
|
15
|
+
The 2024–2025 period has seen the rapid emergence of LLM-specific observability platforms that extend the traditional three pillars with a fourth: **evaluation**—structured assessment of output quality through automated scoring, human annotation, and LLM-as-judge techniques.
|
|
16
|
+
|
|
17
|
+
## Review
|
|
18
|
+
|
|
19
|
+
### OpenTelemetry: The Foundation Layer
|
|
20
|
+
|
|
21
|
+
**Overview:** OpenTelemetry (OTel) is a CNCF (Cloud Native Computing Foundation) project that provides vendor-neutral APIs, SDKs, and tools for generating and collecting telemetry data. It has become the de facto standard for observability instrumentation in cloud-native applications [1][4].
|
|
22
|
+
|
|
23
|
+
**LLM Extensions:** The OpenTelemetry community has developed semantic conventions for LLM operations, defining standard attribute names for:
|
|
24
|
+
- Model name and version
|
|
25
|
+
- Token counts (input, output, total)
|
|
26
|
+
- Prompt and completion content (with optional redaction)
|
|
27
|
+
- Temperature and other generation parameters
|
|
28
|
+
- Cost attribution
|
|
29
|
+
|
|
30
|
+
These conventions enable LLM telemetry to flow through existing OTel infrastructure (collectors, exporters, backends) without requiring LLM-specific tooling for data transport [4][5].
|
|
31
|
+
|
|
32
|
+
**Strengths:**
|
|
33
|
+
- Vendor-neutral: data can be routed to any compatible backend
|
|
34
|
+
- Mature ecosystem: collectors, exporters, and instrumentation libraries for all major languages
|
|
35
|
+
- Standards-based: semantic conventions ensure consistent data representation
|
|
36
|
+
- Composable: LLM traces can be correlated with infrastructure traces for full-stack visibility
|
|
37
|
+
|
|
38
|
+
**Limitations:**
|
|
39
|
+
- Generic by design: LLM-specific concepts (prompt management, evaluation workflows, cost optimization) are not addressed
|
|
40
|
+
- No built-in evaluation: OTel collects data but does not analyze quality
|
|
41
|
+
- Configuration complexity: setting up collectors, exporters, and backends requires significant infrastructure knowledge [6]
|
|
42
|
+
|
|
43
|
+
**Literature Position:** OTel is best understood as a foundation layer—it provides the instrumentation and transport upon which LLM-specific platforms build. Several LLM observability platforms (Langfuse, LangSmith) now support OTel data ingestion, enabling teams to use standard OTel instrumentation while routing LLM-specific data to specialized analysis platforms.
|
|
44
|
+
|
|
45
|
+
### Langfuse: Open-Source LLM Observability
|
|
46
|
+
|
|
47
|
+
**Overview:** Langfuse is an open-source (MIT-licensed) LLM observability platform providing trace-based monitoring, prompt management, evaluation workflows, and cost analytics. It can be self-hosted as a single Docker container or accessed through managed cloud hosting [7][8].
|
|
48
|
+
|
|
49
|
+
**Data Model:** Langfuse implements a hierarchical trace model:
|
|
50
|
+
- **Traces** represent end-to-end executions (user request → final response)
|
|
51
|
+
- **Spans** represent logical subdivisions (retrieval, prompt construction, generation)
|
|
52
|
+
- **Generations** represent specific LLM completions with full prompt/completion capture
|
|
53
|
+
- **Scores** represent quality assessments attached at any level of the hierarchy
|
|
54
|
+
|
|
55
|
+
**Evaluation Capabilities:**
|
|
56
|
+
- LLM-as-Judge: automated quality scoring using a judge model
|
|
57
|
+
- Annotation Queues: human review workflows with structured scoring
|
|
58
|
+
- Dataset Management: curated evaluation sets for regression testing
|
|
59
|
+
- Prompt Experimentation: A/B testing with tracked performance metrics [9]
|
|
60
|
+
|
|
61
|
+
**Literature Assessment:** Langfuse occupies a unique position in the observability landscape: open-source, self-hostable, and increasingly feature-complete. Its MIT license addresses the data sovereignty concerns that prevent many organizations from using cloud-only platforms. As of 2025, all major features (including formerly "Pro" capabilities like LLM-as-judge) are fully open source [10].
|
|
62
|
+
|
|
63
|
+
**Key Publication:** Langfuse's blog post on OpenTelemetry integration (October 2024) is a significant technical document, demonstrating how LLM-specific observability can be built on standardized instrumentation rather than proprietary data collection [4].
|
|
64
|
+
|
|
65
|
+
### LangSmith: LangChain-Native Monitoring
|
|
66
|
+
|
|
67
|
+
**Overview:** LangSmith is the observability platform developed by LangChain Inc., designed for deep integration with LangChain and LangGraph applications. It provides tracing, evaluation, dataset management, and prompt monitoring with tight coupling to the LangChain execution model [11].
|
|
68
|
+
|
|
69
|
+
**Key Features:**
|
|
70
|
+
- Automatic tracing of LangChain chains, agents, and tools
|
|
71
|
+
- End-to-end OpenTelemetry support (announced 2025)
|
|
72
|
+
- Evaluation workflows with human annotation and automated scoring
|
|
73
|
+
- Prompt hub for versioning and sharing prompt templates
|
|
74
|
+
- Regression detection through dataset-based testing
|
|
75
|
+
|
|
76
|
+
**Strengths:**
|
|
77
|
+
- Deepest integration with LangChain/LangGraph ecosystem
|
|
78
|
+
- Most comprehensive evaluation workflow (A/B testing, regression gating, win-rate analysis)
|
|
79
|
+
- Strong enterprise features (access control, compliance, audit trails)
|
|
80
|
+
- OTel bridge enables integration with broader observability infrastructure [11]
|
|
81
|
+
|
|
82
|
+
**Limitations:**
|
|
83
|
+
- Primarily a cloud service (limited self-hosting options)
|
|
84
|
+
- Tightly coupled to LangChain ecosystem
|
|
85
|
+
- Proprietary—dependency on LangChain Inc.'s business model
|
|
86
|
+
|
|
87
|
+
**Literature Assessment:** LangSmith is the most feature-rich LLM observability platform, particularly for teams already invested in the LangChain ecosystem. Its adoption of OpenTelemetry standards signals a convergence in the industry toward standardized instrumentation. However, its cloud-first model and ecosystem coupling create vendor lock-in concerns.
|
|
88
|
+
|
|
89
|
+
### Weights & Biases (W&B Weave): Experiment Tracking to Production
|
|
90
|
+
|
|
91
|
+
**Overview:** Weights & Biases, originally an experiment tracking platform for ML research, has extended into LLM application monitoring through its Weave product. Weave provides tracing, evaluation, and comparison capabilities specifically for LLM applications [12][13].
|
|
92
|
+
|
|
93
|
+
**Key Features:**
|
|
94
|
+
- Side-by-side experiment comparison (prompts, models, parameters)
|
|
95
|
+
- Automatic token and cost tracking
|
|
96
|
+
- Trace-based debugging with full input/output capture
|
|
97
|
+
- Integration with research workflows (MLflow compatibility)
|
|
98
|
+
- Real-time dashboards with custom metrics
|
|
99
|
+
|
|
100
|
+
**Strengths:**
|
|
101
|
+
- Research-to-production continuity: teams using W&B for ML research can extend to LLM monitoring
|
|
102
|
+
- Deep experiment comparison capabilities
|
|
103
|
+
- Strong visualization tools
|
|
104
|
+
- Broad model and framework support
|
|
105
|
+
|
|
106
|
+
**Limitations:**
|
|
107
|
+
- Primarily cloud-hosted
|
|
108
|
+
- Research-oriented UX may not suit operations teams
|
|
109
|
+
- Less LLM-specific than Langfuse or LangSmith
|
|
110
|
+
- Pricing can be significant for high-volume production use [13]
|
|
111
|
+
|
|
112
|
+
**Literature Assessment:** W&B Weave is best suited for teams that bridge research and production—organizations that experiment with different models, prompts, and architectures and need to carry insights from experimentation into production monitoring.
|
|
113
|
+
|
|
114
|
+
### Emerging Platforms
|
|
115
|
+
|
|
116
|
+
Beyond the four primary platforms, the literature notes several emerging tools:
|
|
117
|
+
|
|
118
|
+
- **Arize Phoenix:** Focus on drift detection and production monitoring with strong visualization
|
|
119
|
+
- **Helicone:** No-code observability with particular strength in cost analytics and caching optimization
|
|
120
|
+
- **Maxim AI:** Agent-specific tracing with support for diverse agent architectures
|
|
121
|
+
- **VictoriaMetrics + OTel:** Infrastructure-first approach integrating AI agent observability into existing monitoring stacks [14][15]
|
|
122
|
+
|
|
123
|
+
### Convergence Patterns
|
|
124
|
+
|
|
125
|
+
The literature reveals several convergent trends:
|
|
126
|
+
|
|
127
|
+
1. **Trace/span/generation as standard model.** All platforms have converged on this hierarchical data model, whether they call it "traces" (Langfuse, LangSmith) or "runs" (W&B).
|
|
128
|
+
|
|
129
|
+
2. **OpenTelemetry as foundation.** Langfuse, LangSmith, and emerging platforms increasingly support OTel data ingestion, suggesting convergence on standardized instrumentation.
|
|
130
|
+
|
|
131
|
+
3. **Evaluation as core capability.** All platforms have moved beyond passive observation to active evaluation—automated scoring, human annotation, and regression testing.
|
|
132
|
+
|
|
133
|
+
4. **Cost attribution as first-class concern.** LLM applications have direct, per-request costs that traditional applications lack. All platforms now track and attribute costs.
|
|
134
|
+
|
|
135
|
+
5. **Self-hosting demand.** Data sovereignty requirements are driving open-source and self-hostable solutions, with Langfuse leading this trend.
|
|
136
|
+
|
|
137
|
+
### The Structural Tension Observability Gap
|
|
138
|
+
|
|
139
|
+
The literature reveals a gap in current observability thinking: all platforms treat observability as **problem-detection**—finding errors, identifying bottlenecks, detecting drift. None frame observability as **creative advancement**—measuring progress toward a desired quality standard while maintaining honest current reality assessment.
|
|
140
|
+
|
|
141
|
+
This gap is precisely where structural tension methodology contributes. By mapping:
|
|
142
|
+
- Traces → STC progressions (how is the agent advancing toward its creative goal?)
|
|
143
|
+
- Scores → MMOT evaluations (honest assessment of output quality against Elements of Performance)
|
|
144
|
+
- Reality updates → observation data (what does the observability data tell us about current reality?)
|
|
145
|
+
|
|
146
|
+
...observability transforms from defensive monitoring into a creative instrument that drives purposeful advancement.
|
|
147
|
+
|
|
148
|
+
## Implications for CoAiA.js
|
|
149
|
+
|
|
150
|
+
1. **Langfuse as primary observability backend.** Open-source, self-hostable, and MIT-licensed—aligned with CoAiA.js's zero-dependency philosophy.
|
|
151
|
+
2. **OpenTelemetry instrumentation.** Standard OTel spans for all agent operations, enabling routing to any compatible backend.
|
|
152
|
+
3. **MMOT-as-score integration.** Self-evaluation scores flow to Langfuse as structured quality signals.
|
|
153
|
+
4. **Cost-aware agents.** Token and cost data from Langfuse informs agent decision-making (model selection, context management).
|
|
154
|
+
5. **Creative-orientation observability.** Dashboards frame metrics as tension indicators (how far is current reality from desired outcome?) rather than problem indicators (what's broken?).
|
|
155
|
+
|
|
156
|
+
## Conclusion
|
|
157
|
+
|
|
158
|
+
AI observability has matured rapidly from ad-hoc logging to structured, platform-supported monitoring with evaluation capabilities. The convergence on the trace/span/generation model, OpenTelemetry standardization, and active evaluation workflows provides a solid foundation. The remaining gap—transforming observability from problem-detection to creative advancement—is addressed by integrating structural tension methodology with the observability data model, a contribution that CoAiA.js implements through MMOT-as-score and creative-orientation dashboards.
|
|
159
|
+
|
|
160
|
+
## References
|
|
161
|
+
|
|
162
|
+
1. OpenTelemetry. "What is OpenTelemetry?" https://opentelemetry.io/docs/what-is-opentelemetry/
|
|
163
|
+
2. Glukhov.org. (2024). "Observability for LLM Systems." https://www.glukhov.org/observability/observability-for-llm-systems/
|
|
164
|
+
3. Elysiate. (2025). "LLM Observability: Monitoring, Tracing, and Cost Control." https://www.elysiate.com/blog/llm-observability-monitoring-langsmith-helicone-2025
|
|
165
|
+
4. Langfuse. (2024). "OpenTelemetry for LLM Observability." https://langfuse.com/blog/2024-10-opentelemetry-for-llm-observability
|
|
166
|
+
5. Grafana. (2024). "LLM Observability with OpenTelemetry and Grafana Cloud." https://grafana.com/blog/a-complete-guide-to-llm-observability-with-opentelemetry-and-grafana-cloud/
|
|
167
|
+
6. Spanora AI. (2025). "OpenTelemetry LLM Monitoring." https://spanora.ai/blog/opentelemetry-llm-monitoring
|
|
168
|
+
7. Langfuse GitHub. https://github.com/langfuse/langfuse
|
|
169
|
+
8. Mayol, M. (2025). "Langfuse: The Definitive LLM Observability Platform." https://marcmayol.com/blog/en/langfuse_the_definitive_observability_platform_for_llms_in_2025/
|
|
170
|
+
9. Pondhouse Data. "Langfuse: The Open Source Observability Platform." https://www.pondhouse-data.com/blog/langfuse-observability-platform
|
|
171
|
+
10. It's FOSS. (2025). "LLM Analytics Platform Langfuse Goes Open Source." https://itsfoss.com/news/langfuse-open-source/
|
|
172
|
+
11. LangChain Blog. (2025). "End-to-End OpenTelemetry Support in LangSmith." https://blog.langchain.com/end-to-end-opentelemetry-langsmith/
|
|
173
|
+
12. AI Multiple Research. (2024). "LLM Observability Tools: Weights & Biases, LangSmith." https://research.aimultiple.com/llm-observability/
|
|
174
|
+
13. GetMaxim. (2025). "Top AI Observability Tools in 2025." https://www.getmaxim.ai/articles/top-ai-observability-tools-in-2025-the-ultimate-guide/
|
|
175
|
+
14. VictoriaMetrics. (2025). "AI Agents Observability with OpenTelemetry." https://victoriametrics.com/blog/ai-agents-observability/
|
|
176
|
+
15. DEV Community. (2025). "LLM Observability with OpenTelemetry: A Practical Guide." https://dev.to/kartikdudeja21/llm-observability-with-opentelemetry-a-practical-guide-3clo
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# Literature Review: Prompt Engineering and Decomposition Methodologies
|
|
2
|
+
|
|
3
|
+
> Literature review for the CoAiA.js project — From Chain-of-Thought to Tree-of-Thought, Self-Consistency, and PDE: a review of how prompt decomposition strategies address complexity in LLM applications.
|
|
4
|
+
|
|
5
|
+
## Abstract
|
|
6
|
+
|
|
7
|
+
Prompt engineering has evolved from simple instruction formatting to a sophisticated discipline encompassing reasoning strategies, decomposition techniques, and quality-assurance methodologies. This literature review examines the major prompt decomposition approaches—Chain-of-Thought (CoT), Tree-of-Thought (ToT), Self-Consistency, Decomposed Prompting (DecomP), Plan-and-Solve, and Prompt Decomposition Engineering (PDE)—analyzing their theoretical foundations, empirical effectiveness, and complementary relationships. We identify a critical distinction in the literature between strategies that improve *reasoning quality* (CoT, ToT, Self-Consistency) and strategies that improve *input completeness* (DecomP, PDE), arguing that both categories are necessary for robust AI agent systems. The review situates PDE's unique contribution—extracting implicit intents from hedging language and organizing actions into Four Directions stacks—within this broader landscape.
|
|
8
|
+
|
|
9
|
+
## Introduction
|
|
10
|
+
|
|
11
|
+
The quality of LLM output is profoundly shaped by input construction. A well-structured prompt can transform a mediocre model into an effective problem-solver, while a poorly structured prompt can cause a capable model to miss critical requirements, hallucinate details, or produce superficially correct but substantively incomplete results [1][2].
|
|
12
|
+
|
|
13
|
+
The prompt engineering community has responded with an expanding toolkit of strategies, each addressing different aspects of the prompting challenge. This review organizes these strategies into a taxonomy based on what they optimize, examines their empirical support, and identifies the gaps that remain.
|
|
14
|
+
|
|
15
|
+
## Review
|
|
16
|
+
|
|
17
|
+
### Category 1: Reasoning Enhancement Strategies
|
|
18
|
+
|
|
19
|
+
These strategies improve the quality of the model's reasoning process on a well-specified input.
|
|
20
|
+
|
|
21
|
+
#### Chain-of-Thought Prompting (CoT)
|
|
22
|
+
|
|
23
|
+
**Foundational Work:** Wei et al. (2022) demonstrated that prompting LLMs to show intermediate reasoning steps ("Let's think step by step") dramatically improves performance on multi-step problems, achieving state-of-the-art results on arithmetic, commonsense, and symbolic reasoning benchmarks [3].
|
|
24
|
+
|
|
25
|
+
**Variants:**
|
|
26
|
+
- **Zero-Shot CoT:** Simply adding "Let's think step by step" to any prompt (Kojima et al., 2022)
|
|
27
|
+
- **Few-Shot CoT:** Providing examples with explicit reasoning chains
|
|
28
|
+
- **Auto-CoT:** Automatically generating diverse reasoning demonstrations (Zhang et al., 2022)
|
|
29
|
+
|
|
30
|
+
**Mechanism:** CoT works by encouraging the model to allocate computation to intermediate steps rather than jumping directly to an answer. The intermediate steps serve as a "scratchpad" that keeps the model's reasoning on track [4].
|
|
31
|
+
|
|
32
|
+
**Empirical Support:** Strong and consistent. CoT improves performance on virtually all multi-step reasoning tasks, with gains proportional to task complexity. The technique is most effective for models above ~100B parameters.
|
|
33
|
+
|
|
34
|
+
**Limitations:** CoT improves reasoning fidelity but does not address input completeness. If the prompt contains multiple intents, CoT may reason carefully about a subset while ignoring others. The model's selection of which intents to address remains uncontrolled [5].
|
|
35
|
+
|
|
36
|
+
#### Tree-of-Thought (ToT)
|
|
37
|
+
|
|
38
|
+
**Foundational Work:** Yao et al. (2023) extended CoT from linear reasoning to branching exploration, modeling the reasoning process as a tree where each node represents a partial solution and branches represent alternative reasoning paths [6].
|
|
39
|
+
|
|
40
|
+
**Mechanism:** ToT prompts the model to:
|
|
41
|
+
1. Generate multiple possible next steps at each reasoning node
|
|
42
|
+
2. Evaluate each possibility using a value function (often the model itself)
|
|
43
|
+
3. Prune unpromising branches
|
|
44
|
+
4. Continue exploration along promising paths
|
|
45
|
+
|
|
46
|
+
**Empirical Support:** ToT significantly outperforms CoT on problems requiring exploration—creative tasks, strategic planning, and scenarios with multiple valid approaches. The Game of 24 benchmark showed ToT solving 74% of problems vs. CoT's 4% [6].
|
|
47
|
+
|
|
48
|
+
**Limitations:** ToT is computationally expensive (multiple model calls per reasoning step), introduces additional latency, and is most beneficial for problems where exploration is genuinely valuable. For straightforward sequential tasks, CoT is sufficient and more efficient.
|
|
49
|
+
|
|
50
|
+
**Literature Context:** ToT represents a shift from prompt engineering as input formatting to prompt engineering as search algorithm design. The model becomes a component in a larger reasoning architecture rather than a standalone solution.
|
|
51
|
+
|
|
52
|
+
#### Self-Consistency
|
|
53
|
+
|
|
54
|
+
**Foundational Work:** Wang et al. (2022) proposed sampling multiple independent reasoning paths and selecting the most consistent answer—a technique analogous to ensemble methods in traditional ML [7].
|
|
55
|
+
|
|
56
|
+
**Mechanism:** The model generates N different reasoning chains for the same prompt, each potentially following a different path. The final answer is determined by majority vote across the N chains.
|
|
57
|
+
|
|
58
|
+
**Empirical Support:** Self-Consistency consistently improves upon single-chain CoT, particularly on problems where the reasoning path is ambiguous or where the model's initial reasoning may be led astray by surface-level patterns.
|
|
59
|
+
|
|
60
|
+
**Limitations:** Computational cost scales linearly with N (number of sampled chains). The technique addresses reasoning reliability but not input completeness—all N chains reason about the same (potentially incomplete) interpretation of the input.
|
|
61
|
+
|
|
62
|
+
### Category 2: Task Structure Strategies
|
|
63
|
+
|
|
64
|
+
These strategies address the organization and decomposition of the task itself.
|
|
65
|
+
|
|
66
|
+
#### Decomposed Prompting (DecomP)
|
|
67
|
+
|
|
68
|
+
**Foundational Work:** Khot et al. (2022) proposed decomposing complex questions into simpler sub-questions, each handled by specialized sub-prompts. The key innovation is that different sub-questions can be routed to different models or tools based on their requirements [8].
|
|
69
|
+
|
|
70
|
+
**Mechanism:**
|
|
71
|
+
1. A decomposer module breaks the complex question into sub-questions
|
|
72
|
+
2. Each sub-question is routed to an appropriate handler (LLM, calculator, retriever)
|
|
73
|
+
3. Sub-answers are composed into a final answer
|
|
74
|
+
|
|
75
|
+
**Empirical Support:** DecomP improves performance on multi-hop reasoning, compositional generalization, and long-context tasks by reducing the complexity that any single model call must handle.
|
|
76
|
+
|
|
77
|
+
**Limitations:** DecomP assumes the input question is well-specified—it decomposes the *answer strategy*, not the *question itself*. If the original question contains implicit or hedged intents, DecomP will miss them.
|
|
78
|
+
|
|
79
|
+
#### Plan-and-Solve (PS)
|
|
80
|
+
|
|
81
|
+
**Foundational Work:** Wang et al. (2023) proposed a two-stage approach: first devise a plan for solving the problem, then execute the plan step by step [9].
|
|
82
|
+
|
|
83
|
+
**Mechanism:**
|
|
84
|
+
1. The model generates a plan: "To solve this, I need to: (1) extract data, (2) calculate totals, (3) compare results"
|
|
85
|
+
2. The model executes each plan step sequentially
|
|
86
|
+
|
|
87
|
+
**Empirical Support:** PS improves performance on math word problems and multi-step reasoning tasks by making the execution strategy explicit before execution begins.
|
|
88
|
+
|
|
89
|
+
**Limitations:** The plan is only as good as the model's understanding of the input. If the input contains multiple intents, the plan may address only the salient ones.
|
|
90
|
+
|
|
91
|
+
#### Skeleton-of-Thought (SoT)
|
|
92
|
+
|
|
93
|
+
**Foundational Work:** Ning et al. (2023) proposed generating a "skeleton" answer structure first, then filling in each section in parallel, dramatically reducing latency for long-form generation.
|
|
94
|
+
|
|
95
|
+
**Mechanism:**
|
|
96
|
+
1. Generate a skeleton: section headers or key points
|
|
97
|
+
2. Fill each section independently (can be parallelized)
|
|
98
|
+
3. Compose the final answer
|
|
99
|
+
|
|
100
|
+
**Empirical Support:** SoT reduces latency by 2-3x with comparable or improved quality for long-form outputs.
|
|
101
|
+
|
|
102
|
+
**Relevance to Decomposition:** SoT is relevant because it demonstrates that explicit structural decomposition before generation improves both speed and quality—a principle that PDE extends from output structure to input analysis.
|
|
103
|
+
|
|
104
|
+
### Category 3: Input Completeness Strategies
|
|
105
|
+
|
|
106
|
+
This category, which PDE anchors, addresses the fidelity of intent extraction from complex inputs.
|
|
107
|
+
|
|
108
|
+
#### Prompt Decomposition Engineering (PDE)
|
|
109
|
+
|
|
110
|
+
**Foundational Context:** PDE emerges from the observation that Categories 1 and 2 both assume the model correctly identifies all intents in the input—an assumption that fails for complex, multi-intent, hedging-rich prompts.
|
|
111
|
+
|
|
112
|
+
**Mechanism:**
|
|
113
|
+
1. **Intent Extraction:** The complex prompt is analyzed for primary intents (explicit, unhedged), secondary intents (hedged, conditional), and implicit intents (logically entailed but unstated)
|
|
114
|
+
2. **Dependency Mapping:** Extracted intents are analyzed for prerequisite relationships
|
|
115
|
+
3. **Four Directions Organization:** Intents are organized into East (vision), South (analysis), West (implementation), North (evaluation) stacks
|
|
116
|
+
|
|
117
|
+
**Key Innovation:** PDE's treatment of hedging language as intent signal rather than uncertainty noise. When a user says "maybe also add Husky," PDE captures this as a secondary intent with medium confidence—ensuring it is not dropped during execution.
|
|
118
|
+
|
|
119
|
+
**Theoretical Foundation:** PDE draws from speech act theory (Austin, 1962; Searle, 1969) in treating utterances as actions with varying illocutionary force. "Maybe also configure X" is an indirect speech act—its surface form (suggestion) differs from its underlying intent (request). PDE's hedging detection operationalizes this insight [10].
|
|
120
|
+
|
|
121
|
+
**Empirical Support:** While PDE is newer and less empirically studied than CoT or ToT, its value proposition is validated by the well-documented phenomenon of "prompt drift"—the tendency for LLMs to lose track of secondary intents in complex prompts, a finding consistently reproduced in agent evaluation benchmarks.
|
|
122
|
+
|
|
123
|
+
### Comparative Analysis
|
|
124
|
+
|
|
125
|
+
| Strategy | Optimizes | Input Requirements | Computational Cost | Maturity |
|
|
126
|
+
|----------|-----------|-------------------|-------------------|----------|
|
|
127
|
+
| CoT | Reasoning accuracy | Well-specified question | Low (1 extra pass) | High |
|
|
128
|
+
| ToT | Solution exploration | Well-specified problem | High (N branches × M steps) | Medium |
|
|
129
|
+
| Self-Consistency | Reasoning reliability | Well-specified question | Medium (N samples) | High |
|
|
130
|
+
| DecomP | Complexity management | Well-specified question | Medium (sub-prompts) | Medium |
|
|
131
|
+
| Plan-and-Solve | Execution strategy | Well-specified problem | Low (plan + execute) | Medium |
|
|
132
|
+
| SoT | Generation speed | Clear output structure | Low (skeleton + fill) | Medium |
|
|
133
|
+
| **PDE** | **Input completeness** | **Any complexity** | **Low (one analysis pass)** | **Early** |
|
|
134
|
+
|
|
135
|
+
### Complementary Relationships
|
|
136
|
+
|
|
137
|
+
The strategies are not competing but complementary, addressing different stages of the prompt-to-output pipeline:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
User Input → [PDE: ensure completeness] → [PS: plan strategy] →
|
|
141
|
+
[CoT/ToT: reason carefully] → [Self-Consistency: verify] → Output
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
PDE operates at the earliest stage—ensuring that all intents are captured before any reasoning strategy is applied. Its output feeds into Plan-and-Solve (which creates execution plans for each extracted intent), Chain-of-Thought (which reasons carefully about each step), and Self-Consistency (which verifies the reasoning).
|
|
145
|
+
|
|
146
|
+
### Reflexion and Self-Improvement
|
|
147
|
+
|
|
148
|
+
Shinn et al. (2023) introduced Reflexion—prompting agents to reflect on their own outputs and identify errors for correction. This is relevant to the decomposition landscape because it addresses a failure mode that all prior strategies share: what happens when the model executes correctly but misinterpreted the input?
|
|
149
|
+
|
|
150
|
+
Reflexion operates as a post-hoc correction mechanism. PDE operates as a pre-hoc prevention mechanism. Both are valuable; their combination provides the strongest completeness guarantee [11].
|
|
151
|
+
|
|
152
|
+
### Meta-Prompting and Prompt Chaining
|
|
153
|
+
|
|
154
|
+
The literature also notes the importance of prompt chaining—linking multiple prompt responses into explicit multi-stage workflows. This pattern is the operational foundation for PDE: the decomposition analysis is one prompt, and each extracted intent is executed through subsequent prompts, potentially with different reasoning strategies applied to each.
|
|
155
|
+
|
|
156
|
+
## Implications for CoAiA.js
|
|
157
|
+
|
|
158
|
+
1. **PDE as session entry point.** Every CoAiA.js session begins with PDE decomposition, ensuring completeness before reasoning begins.
|
|
159
|
+
2. **Strategy composition.** After PDE extracts intents, each intent can use the appropriate reasoning strategy (CoT for sequential tasks, ToT for creative tasks).
|
|
160
|
+
3. **Four Directions alignment.** PDE's Four Directions output stack maps directly to CoAiA.js's directional agent orchestration.
|
|
161
|
+
4. **MMOT as Reflexion.** The MMOT evaluation cycle serves as the post-hoc completeness verification that Reflexion provides, checking whether all PDE-extracted intents were addressed.
|
|
162
|
+
5. **Hedging-aware agents.** CoAiA.js agents treat hedged requests as real requests with reduced confidence, preventing the intent loss that plagues naive prompt processing.
|
|
163
|
+
|
|
164
|
+
## Conclusion
|
|
165
|
+
|
|
166
|
+
The prompt decomposition literature reveals a rich but incomplete landscape. Reasoning enhancement strategies (CoT, ToT, Self-Consistency) and task structure strategies (DecomP, PS, SoT) have achieved significant advances in the quality and organization of LLM outputs. However, they share a common blind spot: the assumption that the input prompt has been correctly and completely understood. PDE addresses this blind spot by operating on the input itself—extracting all intents (including implicit and hedged ones), mapping dependencies, and organizing them for systematic execution. The combination of input completeness (PDE) with reasoning quality (CoT/ToT) and post-hoc verification (Reflexion/MMOT) provides the most robust foundation for complex AI agent operations.
|
|
167
|
+
|
|
168
|
+
## References
|
|
169
|
+
|
|
170
|
+
1. LearnPrompting.org. (2024). "Advanced Decomposition Techniques for Improved Prompting." https://learnprompting.org/docs/advanced/decomposition/introduction
|
|
171
|
+
2. Coupler.io. (2024). "Advanced Prompting Techniques for Complex AI Reasoning." https://blog.coupler.io/advanced-prompting-techniques/
|
|
172
|
+
3. Wei, J., et al. (2022). "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models." *NeurIPS 2022*.
|
|
173
|
+
4. Toward Data Science. (2024). "Advanced Prompt Engineering: Chain of Thought." https://towardsdatascience.com/advanced-prompt-engineering-chain-of-thought-cot-8d8b090bf699/
|
|
174
|
+
5. CalmOps. (2024). "Prompt Engineering Patterns: CoT, ReAct, and ToT." https://calmops.com/ai/prompt-engineering-patterns-cot-react-tot/
|
|
175
|
+
6. Yao, S., et al. (2023). "Tree of Thoughts: Deliberate Problem Solving with Large Language Models." *NeurIPS 2023*.
|
|
176
|
+
7. Wang, X., et al. (2022). "Self-Consistency Improves Chain of Thought Reasoning in Language Models." *ICLR 2023*.
|
|
177
|
+
8. Khot, T., et al. (2022). "Decomposed Prompting: A Modular Approach for Solving Complex Tasks." *ICLR 2023*.
|
|
178
|
+
9. Wang, L., et al. (2023). "Plan-and-Solve Prompting: Improving Zero-Shot Chain-of-Thought Reasoning." *ACL 2023*.
|
|
179
|
+
10. Searle, J. R. (1969). *Speech Acts: An Essay in the Philosophy of Language*. Cambridge University Press.
|
|
180
|
+
11. Shinn, N., et al. (2023). "Reflexion: Language Agents with Verbal Reinforcement Learning." *NeurIPS 2023*.
|
|
181
|
+
12. Oxen.ai. (2024). "The Prompt Report Part 2." https://ghost.oxen.ai/the-prompt-report-part-2-thought-generation-tree-of-thought-and-decomposition-prompting/
|
|
182
|
+
13. Exploratio Journal. (2024). "Zooming-in On Prompting: A Comparative Study." https://exploratiojournal.com/zooming-in-on-prompting/
|
|
183
|
+
14. Metric Coders. (2024). "Complex Reasoning with Chain-of-Thought, Tree-of-Thought, and More." https://www.metriccoders.com/post/beyond-the-basics-unleashing-complex-reasoning-with-chain-of-thought-tree-of-thought-and-more
|
|
184
|
+
15. Fedotov, I. (2024). "Advanced Prompt Engineering Techniques: From Tree of Thoughts to Multimodal AI." https://ilyafedotov.com/advanced-prompt-engineering-techniques-from-tree-of-thoughts-to-multimodal-ai/
|