rhachet-roles-bhrain 0.1.1 → 0.3.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.
Files changed (159) hide show
  1. package/dist/.test/getContextOpenAI.js +1 -1
  2. package/dist/.test/getContextOpenAI.js.map +1 -1
  3. package/dist/domain.operations/review/compileReviewPrompt.d.ts +22 -0
  4. package/dist/domain.operations/review/compileReviewPrompt.js +95 -0
  5. package/dist/domain.operations/review/compileReviewPrompt.js.map +1 -0
  6. package/dist/domain.operations/review/enumFilesFromDiffs.d.ts +8 -0
  7. package/dist/domain.operations/review/enumFilesFromDiffs.js +74 -0
  8. package/dist/domain.operations/review/enumFilesFromDiffs.js.map +1 -0
  9. package/dist/domain.operations/review/enumFilesFromGlob.d.ts +8 -0
  10. package/dist/domain.operations/review/enumFilesFromGlob.js +31 -0
  11. package/dist/domain.operations/review/enumFilesFromGlob.js.map +1 -0
  12. package/dist/domain.operations/review/estimateTokenCount.d.ts +9 -0
  13. package/dist/domain.operations/review/estimateTokenCount.js +20 -0
  14. package/dist/domain.operations/review/estimateTokenCount.js.map +1 -0
  15. package/dist/domain.operations/review/formatReviewOutput.d.ts +14 -0
  16. package/dist/domain.operations/review/formatReviewOutput.js +42 -0
  17. package/dist/domain.operations/review/formatReviewOutput.js.map +1 -0
  18. package/dist/domain.operations/review/genTokenBreakdownMarkdown.d.ts +19 -0
  19. package/dist/domain.operations/review/genTokenBreakdownMarkdown.js +110 -0
  20. package/dist/domain.operations/review/genTokenBreakdownMarkdown.js.map +1 -0
  21. package/dist/domain.operations/review/genTokenBreakdownReport.d.ts +24 -0
  22. package/dist/domain.operations/review/genTokenBreakdownReport.js +64 -0
  23. package/dist/domain.operations/review/genTokenBreakdownReport.js.map +1 -0
  24. package/dist/domain.operations/review/invokeClaudeCode.d.ts +22 -0
  25. package/dist/domain.operations/review/invokeClaudeCode.js +92 -0
  26. package/dist/domain.operations/review/invokeClaudeCode.js.map +1 -0
  27. package/dist/domain.operations/review/writeInputArtifacts.d.ts +27 -0
  28. package/dist/domain.operations/review/writeInputArtifacts.js +50 -0
  29. package/dist/domain.operations/review/writeInputArtifacts.js.map +1 -0
  30. package/dist/domain.operations/review/writeOutputArtifacts.d.ts +12 -0
  31. package/dist/domain.operations/review/writeOutputArtifacts.js +46 -0
  32. package/dist/domain.operations/review/writeOutputArtifacts.js.map +1 -0
  33. package/dist/roles/architect/briefs/brains.replic/arc000.sources.[catalog].md +178 -0
  34. package/dist/roles/architect/briefs/brains.replic/arc101.concept.llm.[article].md +25 -0
  35. package/dist/roles/architect/briefs/brains.replic/arc102.concept.repl.[article].md +33 -0
  36. package/dist/roles/architect/briefs/brains.replic/arc103.concept.replic-brain.[article].md +35 -0
  37. package/dist/roles/architect/briefs/brains.replic/arc104.concept.context-window.[article].md +40 -0
  38. package/dist/roles/architect/briefs/brains.replic/arc105.concept.system-prompt.[article].md +44 -0
  39. package/dist/roles/architect/briefs/brains.replic/arc106.concept.tool-definition.[article].md +59 -0
  40. package/dist/roles/architect/briefs/brains.replic/arc107.concept.tool-call.[article].md +54 -0
  41. package/dist/roles/architect/briefs/brains.replic/arc108.concept.tool-result.[article].md +58 -0
  42. package/dist/roles/architect/briefs/brains.replic/arc109.concept.agentic-loop.[article].md +62 -0
  43. package/dist/roles/architect/briefs/brains.replic/arc110.concept.reasoning-trace.[article].md +58 -0
  44. package/dist/roles/architect/briefs/brains.replic/arc111.concept.react-pattern.[article].md +65 -0
  45. package/dist/roles/architect/briefs/brains.replic/arc112.concept.reflexion-pattern.[article].md +68 -0
  46. package/dist/roles/architect/briefs/brains.replic/arc113.concept.tree-of-thoughts.[article].md +76 -0
  47. package/dist/roles/architect/briefs/brains.replic/arc114.concept.self-consistency.[article].md +73 -0
  48. package/dist/roles/architect/briefs/brains.replic/arc115.concept.lats-pattern.[article].md +78 -0
  49. package/dist/roles/architect/briefs/brains.replic/arc116.concept.context-compaction.[article].md +71 -0
  50. package/dist/roles/architect/briefs/brains.replic/arc117.concept.subagent.[article].md +71 -0
  51. package/dist/roles/architect/briefs/brains.replic/arc118.concept.extended-thinking.[article].md +69 -0
  52. package/dist/roles/architect/briefs/brains.replic/arc119.concept.mcp.[article].md +78 -0
  53. package/dist/roles/architect/briefs/brains.replic/arc120.concept.session.[article].md +67 -0
  54. package/dist/roles/architect/briefs/brains.replic/arc121.concept.message.[article].md +79 -0
  55. package/dist/roles/architect/briefs/brains.replic/arc122.concept.plan-and-solve.[article].md +80 -0
  56. package/dist/roles/architect/briefs/brains.replic/arc150.concepts.treestruct.[article].md +126 -0
  57. package/dist/roles/architect/briefs/brains.replic/arc201.blueprint.claude-code.[article].md +417 -0
  58. package/dist/roles/architect/briefs/brains.replic/arc201.blueprint.claude-code.zoomin.reason.[article].md +507 -0
  59. package/dist/roles/architect/briefs/brains.replic/arc202.blueprint.codex.[article].md +354 -0
  60. package/dist/roles/architect/briefs/brains.replic/arc300.blueprints.comparison.[catalog].md +284 -0
  61. package/dist/roles/getRoleRegistry.js +2 -1
  62. package/dist/roles/getRoleRegistry.js.map +1 -1
  63. package/dist/roles/getRoleRegistry.readme.js +6 -0
  64. package/dist/roles/getRoleRegistry.readme.js.map +1 -1
  65. package/dist/roles/reviewer/briefs/review.tactics.md +60 -0
  66. package/dist/roles/reviewer/getReviewerRole.d.ts +6 -0
  67. package/dist/roles/reviewer/getReviewerRole.js +80 -0
  68. package/dist/roles/reviewer/getReviewerRole.js.map +1 -0
  69. package/dist/roles/reviewer/skills/review/review.d.ts +57 -0
  70. package/dist/roles/reviewer/skills/review/review.js +445 -0
  71. package/dist/roles/reviewer/skills/review/review.js.map +1 -0
  72. package/dist/roles/reviewer/skills/review/review.sh +21 -0
  73. package/dist/roles/reviewer/skills/review/review.ts +575 -0
  74. package/dist/roles/thinker/briefs/term=brain.atomic_vs_replic.md +8 -0
  75. package/dist/roles/thinker/getThinkerRole.js +1 -1
  76. package/dist/roles/thinker/getThinkerRole.js.map +1 -1
  77. package/dist/roles/thinker/skills/brief.articulate/.demo/article.vision.v2025_08_19..i1.via_chatgpt.md +47 -0
  78. package/dist/roles/thinker/skills/brief.articulate/.demo/article.vision.v2025_08_19.i2.via_rhachet.md +60 -0
  79. package/dist/roles/thinker/skills/brief.articulate/.demo/diverge.v2025_08_17.i1.md +62 -0
  80. package/dist/roles/thinker/skills/brief.articulate/.demo/diverge.v2025_08_17.i1.with_feedback.md +89 -0
  81. package/dist/roles/thinker/skills/brief.articulate/.demo/diverge.v2025_08_17.i2.md +47 -0
  82. package/dist/roles/thinker/skills/brief.articulate/.demo/joke.v2025_08_15.i1.md +44 -0
  83. package/dist/roles/thinker/skills/brief.articulate/.demo/joke.v2025_08_15.i2.md +63 -0
  84. package/dist/roles/thinker/skills/brief.articulate/.demo/joke.v2025_08_15.i3.md +51 -0
  85. package/dist/roles/thinker/skills/brief.articulate/.demo/user-journey.v2025_08_17.i1.md +62 -0
  86. package/dist/roles/thinker/skills/brief.articulate/.demo/user-journey.v2025_08_17.i2.md +49 -0
  87. package/dist/roles/thinker/skills/brief.articulate/.readme.md +0 -0
  88. package/dist/roles/thinker/skills/brief.articulate/stepArticulate.skill.js +1 -1
  89. package/dist/roles/thinker/skills/brief.articulate/stepArticulate.skill.js.map +1 -1
  90. package/dist/roles/thinker/skills/brief.articulate/stepArticulate.skill.ts +168 -0
  91. package/dist/roles/thinker/skills/brief.articulate/stepArticulate.ts +157 -0
  92. package/dist/roles/thinker/skills/brief.catalogize/.demo/joke.types.v2025_08_28.i1.md +93 -0
  93. package/dist/roles/thinker/skills/brief.catalogize/.demo/joke.types.v2025_08_28.i2.md +84 -0
  94. package/dist/roles/thinker/skills/brief.catalogize/.demo/joke.types.v2025_09_28.i1.no_focus_context.md +8 -0
  95. package/dist/roles/thinker/skills/brief.catalogize/.demo/joke.types.v2025_09_28.i2.md +54 -0
  96. package/dist/roles/thinker/skills/brief.catalogize/.demo/persona.usecases.v2025_08_28.i1.md +62 -0
  97. package/dist/roles/thinker/skills/brief.catalogize/.demo/persona.usecases.v2025_08_28.i2.md +64 -0
  98. package/dist/roles/thinker/skills/brief.catalogize/.readme.md +5 -0
  99. package/dist/roles/thinker/skills/brief.catalogize/stepCatalogize.skill.js +1 -1
  100. package/dist/roles/thinker/skills/brief.catalogize/stepCatalogize.skill.js.map +1 -1
  101. package/dist/roles/thinker/skills/brief.catalogize/stepCatalogize.skill.ts +173 -0
  102. package/dist/roles/thinker/skills/brief.catalogize/stepCatalogize.ts +132 -0
  103. package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.input.example.i4.md +3 -0
  104. package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.input.example.i5.md +3 -0
  105. package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.input.example.i6.md +3 -0
  106. package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.input.example.md +3 -0
  107. package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.v2025_08_27.i1.md +52 -0
  108. package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.v2025_08_27.i2.md +51 -0
  109. package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.v2025_08_27.i3.md +47 -0
  110. package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.v2025_08_27.i4.md +62 -0
  111. package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.v2025_08_27.i5.md +47 -0
  112. package/dist/roles/thinker/skills/brief.demonstrate/.demo/user.journey.roadtrip.v2025_08_27.i6.md +53 -0
  113. package/dist/roles/thinker/skills/brief.demonstrate/.readme +3 -0
  114. package/dist/roles/thinker/skills/brief.demonstrate/stepDemonstrate.skill.js +1 -1
  115. package/dist/roles/thinker/skills/brief.demonstrate/stepDemonstrate.skill.js.map +1 -1
  116. package/dist/roles/thinker/skills/brief.demonstrate/stepDemonstrate.skill.ts +190 -0
  117. package/dist/roles/thinker/skills/brief.demonstrate/stepDemonstrate.ts +164 -0
  118. package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input1.cluster.v2025_08_17.i1.md +72 -0
  119. package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input1.cluster.v2025_08_17.i2.md +53 -0
  120. package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input1.cluster.v2025_08_17.i3.which_objectives.md +58 -0
  121. package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input1.cluster.v2025_08_17.i5.which_personas.md +64 -0
  122. package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input2.cluster.v2025_08_17.i1.md +67 -0
  123. package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input2.cluster.v2025_08_17.i2.md +49 -0
  124. package/dist/roles/thinker/skills/khue.cluster/.demo/user.journeys.input2.cluster.v2025_08_17.i3.md +59 -0
  125. package/dist/roles/thinker/skills/khue.cluster/.readme.md +0 -0
  126. package/dist/roles/thinker/skills/khue.cluster/stepCluster.skill.js +1 -1
  127. package/dist/roles/thinker/skills/khue.cluster/stepCluster.skill.js.map +1 -1
  128. package/dist/roles/thinker/skills/khue.cluster/stepCluster.skill.ts +174 -0
  129. package/dist/roles/thinker/skills/khue.cluster/stepCluster.ts +150 -0
  130. package/dist/roles/thinker/skills/khue.decompose/.readme.md +9 -0
  131. package/dist/roles/thinker/skills/khue.diverge/.demo/joke.examples.v2025_08_17.i2.md +23 -0
  132. package/dist/roles/thinker/skills/khue.diverge/.demo/joke.examples.v2025_08_17.i3.md +23 -0
  133. package/dist/roles/thinker/skills/khue.diverge/.demo/joke.varieties.v2025_08_17.i1.md +23 -0
  134. package/dist/roles/thinker/skills/khue.diverge/.demo/userjourney.examples.v2025_08_17.i1.md +9 -0
  135. package/dist/roles/thinker/skills/khue.diverge/.demo/userjourney.examples.v2025_08_17.i2.md +9 -0
  136. package/dist/roles/thinker/skills/khue.diverge/.demo/userjourney.examples.v2025_08_17.i3.md +23 -0
  137. package/dist/roles/thinker/skills/khue.diverge/.demo/userjourney.examples.v2025_08_17.i4.folksy.md +9 -0
  138. package/dist/roles/thinker/skills/khue.diverge/.demo/userjourney.examples.v2025_08_17.i5.folksy.md +23 -0
  139. package/dist/roles/thinker/skills/khue.diverge/.readme.md +0 -0
  140. package/dist/roles/thinker/skills/khue.diverge/stepDiverge.skill.js +1 -1
  141. package/dist/roles/thinker/skills/khue.diverge/stepDiverge.skill.js.map +1 -1
  142. package/dist/roles/thinker/skills/khue.diverge/stepDiverge.skill.ts +149 -0
  143. package/dist/roles/thinker/skills/khue.diverge/stepDiverge.ts +151 -0
  144. package/dist/roles/thinker/skills/khue.encompose/.readme.md +7 -0
  145. package/dist/roles/thinker/skills/khue.instantiate/.readme.md +14 -0
  146. package/dist/roles/thinker/skills/khue.instantiate/stepInstantiate.skill.js +1 -1
  147. package/dist/roles/thinker/skills/khue.instantiate/stepInstantiate.skill.js.map +1 -1
  148. package/dist/roles/thinker/skills/khue.instantiate/stepInstantiate.skill.ts +190 -0
  149. package/dist/roles/thinker/skills/khue.instantiate/stepInstantiate.ts +132 -0
  150. package/dist/roles/thinker/skills/khue.triage/.demo/laughs.v2025_08_18.i1.md +29 -0
  151. package/dist/roles/thinker/skills/khue.triage/.demo/user.journeys.v2025_08_17.i1.md +86 -0
  152. package/dist/roles/thinker/skills/khue.triage/.demo/user.journeys.v2025_08_17.i2.md +68 -0
  153. package/dist/roles/thinker/skills/khue.triage/.readme.md +0 -0
  154. package/dist/roles/thinker/skills/khue.triage/stepTriage.skill.js +1 -1
  155. package/dist/roles/thinker/skills/khue.triage/stepTriage.skill.js.map +1 -1
  156. package/dist/roles/thinker/skills/khue.triage/stepTriage.skill.ts +174 -0
  157. package/dist/roles/thinker/skills/khue.triage/stepTriage.ts +153 -0
  158. package/package.json +9 -7
  159. package/readme.md +55 -0
@@ -0,0 +1,59 @@
1
+ # tool-definition
2
+
3
+ ## .what
4
+
5
+ a schema that describes a tool's interface — its name, purpose, parameters, and expected behavior — enabling an llm to understand when and how to invoke it.
6
+
7
+ ## .why
8
+
9
+ tool definitions are the contract between the llm and external capabilities. by providing structured schemas, the llm can reason about which tools apply to a task, what parameters to provide, and what results to expect. well-designed tool definitions are essential for reliable agent behavior.
10
+
11
+ ## dependsOn
12
+
13
+ - `system-prompt` — tool definitions are typically included in system prompt
14
+ - `llm` — interprets tool definitions and decides when to invoke
15
+
16
+ ## key characteristics
17
+
18
+ - **name**: unique identifier for the tool
19
+ - **description**: natural language explanation of purpose
20
+ - **parameters**: typed schema (often JSON Schema) for inputs
21
+ - **returns**: description of expected output format
22
+
23
+ ## example schema
24
+
25
+ ```json
26
+ {
27
+ "name": "Read",
28
+ "description": "Reads a file from the filesystem",
29
+ "parameters": {
30
+ "type": "object",
31
+ "properties": {
32
+ "file_path": {
33
+ "type": "string",
34
+ "description": "Absolute path to the file"
35
+ },
36
+ "offset": {
37
+ "type": "number",
38
+ "description": "Line number to start reading from"
39
+ }
40
+ },
41
+ "required": ["file_path"]
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## tool categories (replic brains)
47
+
48
+ | category | examples |
49
+ |----------|----------|
50
+ | filesystem | Read, Write, Edit, Glob, Grep |
51
+ | execution | Bash, Task |
52
+ | communication | WebSearch, WebFetch |
53
+ | coordination | TodoWrite, AskUserQuestion |
54
+
55
+ ## sources
56
+
57
+ - [Advanced Tool Use on Claude](https://www.anthropic.com/engineering/advanced-tool-use) — tool definition patterns
58
+ - [Toolformer](https://arxiv.org/abs/2302.04761) — self-supervised tool learning
59
+ - [MCP Specification](https://modelcontextprotocol.io/) — standardized tool protocol
@@ -0,0 +1,54 @@
1
+ # tool-call
2
+
3
+ ## .what
4
+
5
+ a structured request generated by an llm to invoke a specific tool with given parameters, representing the agent's decision to take an external action.
6
+
7
+ ## .why
8
+
9
+ tool calls are the mechanism by which replic brains interact with the world beyond text generation. when the llm determines that a task requires external action — reading a file, executing code, searching the web — it emits a tool call. this is the bridge between reasoning and action.
10
+
11
+ ## dependsOn
12
+
13
+ - `tool-definition` — provides the schema for valid calls
14
+ - `llm` — generates the tool call
15
+ - `agentic-loop` — processes and executes the call
16
+
17
+ ## key characteristics
18
+
19
+ - **structured**: follows the schema defined in tool-definition
20
+ - **atomic**: one tool call = one action
21
+ - **declarative**: specifies what to do, not how
22
+ - **interruptible**: execution may require user approval
23
+
24
+ ## example
25
+
26
+ ```json
27
+ {
28
+ "tool": "Read",
29
+ "parameters": {
30
+ "file_path": "/home/user/project/src/main.ts",
31
+ "offset": 100,
32
+ "limit": 50
33
+ }
34
+ }
35
+ ```
36
+
37
+ ## lifecycle
38
+
39
+ 1. llm generates tool call in response
40
+ 2. system extracts and validates parameters
41
+ 3. permission check (if required)
42
+ 4. tool executes
43
+ 5. result returned to context as `tool-result`
44
+
45
+ ## parallelism
46
+
47
+ some systems allow multiple tool calls in a single response:
48
+ - **independent calls**: can execute in parallel
49
+ - **dependent calls**: must execute sequentially
50
+
51
+ ## sources
52
+
53
+ - [ReAct](https://arxiv.org/abs/2210.03629) — action in reasoning+acting loop
54
+ - [Building Effective Agents](https://www.anthropic.com/research/building-effective-agents) — tool call patterns
@@ -0,0 +1,58 @@
1
+ # tool-result
2
+
3
+ ## .what
4
+
5
+ the output returned from executing a tool call, injected back into the llm's context as feedback for continued reasoning.
6
+
7
+ ## .why
8
+
9
+ tool results close the feedback loop in agentic systems. they allow the llm to observe the consequences of its actions, verify success or failure, and adjust its approach. without tool results, the agent would be operating blind.
10
+
11
+ ## dependsOn
12
+
13
+ - `tool-call` — produces the result
14
+ - `context-window` — result consumes context tokens
15
+
16
+ ## key characteristics
17
+
18
+ - **structured or text**: depends on tool (json, stdout, file contents)
19
+ - **may be truncated**: large outputs compressed to fit context
20
+ - **includes metadata**: success/failure, error messages
21
+ - **grounds reasoning**: provides factual information
22
+
23
+ ## example
24
+
25
+ ```
26
+ Tool Result (Read):
27
+ 1→import { Component } from 'react';
28
+ 2→
29
+ 3→export class App extends Component {
30
+ 4→ render() {
31
+ 5→ return <div>Hello World</div>;
32
+ 6→ }
33
+ 7→}
34
+ ```
35
+
36
+ ## handling large results
37
+
38
+ | strategy | description |
39
+ |----------|-------------|
40
+ | truncation | cut output at N characters/lines |
41
+ | summarization | llm summarizes before adding to context |
42
+ | pagination | return chunks with offset/limit |
43
+ | streaming | process incrementally |
44
+
45
+ ## error results
46
+
47
+ tool results may indicate failures:
48
+ - file not found
49
+ - permission denied
50
+ - timeout exceeded
51
+ - invalid parameters
52
+
53
+ the llm must interpret these and adapt its approach.
54
+
55
+ ## sources
56
+
57
+ - [ReAct](https://arxiv.org/abs/2210.03629) — observation in ReAct loop
58
+ - [Inner Monologue](https://arxiv.org/abs/2207.05608) — environment feedback
@@ -0,0 +1,62 @@
1
+ # agentic-loop
2
+
3
+ ## .what
4
+
5
+ the core execution pattern of replic brains: repeatedly generate llm response, check for tool calls, execute tools, append results, and continue until task completion.
6
+
7
+ ## .why
8
+
9
+ the agentic loop is what transforms a stateless llm into a persistent, goal-directed agent. by iterating through generate → execute → observe cycles, the agent can accomplish complex multi-step tasks that exceed what a single generation could produce.
10
+
11
+ ## dependsOn
12
+
13
+ - `llm` — generates responses and tool calls
14
+ - `repl` — the agentic loop is the repl pattern applied to llms
15
+ - `tool-call` — actions to execute
16
+ - `tool-result` — feedback from actions
17
+ - `context-window` — accumulates conversation history
18
+
19
+ ## pseudocode
20
+
21
+ ```python
22
+ while True:
23
+ response = llm.generate(context_window)
24
+
25
+ if response.has_tool_calls:
26
+ for tool_call in response.tool_calls:
27
+ result = execute_tool(tool_call)
28
+ context_window.append(result)
29
+ else:
30
+ return response # task complete, exit loop
31
+ ```
32
+
33
+ ## key characteristics
34
+
35
+ - **unbounded iteration**: continues until llm stops calling tools
36
+ - **context accumulation**: history grows with each turn
37
+ - **goal-directed**: llm decides when task is complete
38
+ - **interruptible**: user can inject messages mid-loop
39
+
40
+ ## termination conditions
41
+
42
+ | condition | trigger |
43
+ | ------------------ | ------------------------------- |
44
+ | natural completion | llm responds without tool calls |
45
+ | context exhaustion | context window fills up |
46
+ | user interruption | user sends new message |
47
+ | timeout | max iterations or time exceeded |
48
+ | error | unrecoverable tool failure |
49
+
50
+ ## variants
51
+
52
+ | variant | modification |
53
+ | ----------- | ------------------------------------ |
54
+ | react | interleave explicit reasoning traces |
55
+ | reflexion | add self-reflection after failures |
56
+ | tree search | explore multiple action branches |
57
+
58
+ ## sources
59
+
60
+ - [Building Effective Agents](https://www.anthropic.com/research/building-effective-agents) — canonical loop description
61
+ - [ReAct](https://arxiv.org/abs/2210.03629) — reasoning-augmented loop
62
+ - [CoALA](https://arxiv.org/abs/2309.02427) — framework for loop variants
@@ -0,0 +1,58 @@
1
+ # reasoning-trace
2
+
3
+ ## .what
4
+
5
+ explicit intermediate reasoning steps that an llm produces before generating a final answer, making its thought process visible and improving accuracy on complex tasks.
6
+
7
+ ## .why
8
+
9
+ reasoning traces transform black-box generation into interpretable problem-solving. by externalizing intermediate steps, the llm can break down complex problems, catch errors in its reasoning, and provide explanations that humans can verify. this is the foundation for chain-of-thought and related techniques.
10
+
11
+ ## dependsOn
12
+
13
+ - `llm` — generates the reasoning trace
14
+ - `context-window` — traces consume tokens
15
+
16
+ ## key characteristics
17
+
18
+ - **intermediate**: produced before final answer
19
+ - **natural language**: typically readable text
20
+ - **step-by-step**: decomposed reasoning
21
+ - **self-documenting**: explains the llm's approach
22
+
23
+ ## example
24
+
25
+ ```
26
+ Question: What is 23 × 17?
27
+
28
+ Reasoning trace:
29
+ - I need to multiply 23 by 17
30
+ - 23 × 17 = 23 × (10 + 7)
31
+ - = 23 × 10 + 23 × 7
32
+ - = 230 + 161
33
+ - = 391
34
+
35
+ Answer: 391
36
+ ```
37
+
38
+ ## elicitation methods
39
+
40
+ | method | technique |
41
+ |--------|-----------|
42
+ | zero-shot | "Let's think step by step" |
43
+ | few-shot | provide example traces |
44
+ | trained | fine-tune on trace datasets |
45
+ | scratchpad | dedicated trace output space |
46
+
47
+ ## benefits
48
+
49
+ - improved accuracy on reasoning tasks
50
+ - reduced hallucination
51
+ - debuggable/auditable outputs
52
+ - enables self-correction
53
+
54
+ ## sources
55
+
56
+ - [Chain-of-Thought Prompting](https://arxiv.org/abs/2201.11903) — seminal paper
57
+ - [Scratchpads](https://arxiv.org/abs/2112.00114) — intermediate computation
58
+ - [Extended Thinking](https://www.anthropic.com/news/visible-extended-thinking) — claude's thinking mode
@@ -0,0 +1,65 @@
1
+ # react-pattern
2
+
3
+ ## .what
4
+
5
+ a prompting paradigm that interleaves reasoning traces with actions, producing explicit Thought → Action → Observation cycles that ground reasoning in real-world feedback.
6
+
7
+ ## .why
8
+
9
+ react addresses a fundamental limitation of pure reasoning: hallucination. by forcing the model to take actions and observe actual results between reasoning steps, react grounds abstract thought in concrete feedback. this synergy of reasoning and acting enables more reliable task completion.
10
+
11
+ ## dependsOn
12
+
13
+ - `reasoning-trace` — the "thought" component
14
+ - `tool-call` — the "action" component
15
+ - `tool-result` — the "observation" component
16
+ - `agentic-loop` — orchestrates the cycle
17
+
18
+ ## pattern structure
19
+
20
+ ```
21
+ Thought: I need to find information about X
22
+ Action: Search("X")
23
+ Observation: [search results]
24
+ Thought: Based on these results, I should check Y
25
+ Action: Read("file_y.txt")
26
+ Observation: [file contents]
27
+ Thought: Now I can answer the question
28
+ Answer: ...
29
+ ```
30
+
31
+ ## benchmark performance
32
+
33
+ | benchmark | react vs baseline |
34
+ |-----------|-------------------|
35
+ | HotPotQA | competitive with CoT, lower hallucination (6% vs 14%) |
36
+ | ALFWorld | +34% over imitation learning |
37
+ | WebShop | significantly outperforms Act-only |
38
+
39
+ ## tradeoffs
40
+
41
+ ### strengths
42
+ - grounded in real observations
43
+ - lower hallucination rate
44
+ - interpretable decision process
45
+ - recovers from errors via feedback
46
+
47
+ ### weaknesses
48
+ - structurally constrained (forced action after each thought)
49
+ - dependent on quality of retrieved information
50
+ - may force unnecessary actions
51
+
52
+ ## comparison with pure CoT
53
+
54
+ | aspect | CoT | ReAct |
55
+ |--------|-----|-------|
56
+ | grounding | internal only | external observations |
57
+ | hallucination | higher | lower |
58
+ | flexibility | high | constrained by structure |
59
+ | task types | reasoning | reasoning + interaction |
60
+
61
+ ## sources
62
+
63
+ - [ReAct: Synergizing Reasoning and Acting](https://arxiv.org/abs/2210.03629) — original paper (ICLR 2023)
64
+ - [Google Research Blog](https://research.google/blog/react-synergizing-reasoning-and-acting-in-language-models/) — overview
65
+ - [Comprehensive Guide to ReAct](https://www.mercity.ai/blog-post/react-prompting-and-react-based-agentic-systems) — practical guide
@@ -0,0 +1,68 @@
1
+ # reflexion-pattern
2
+
3
+ ## .what
4
+
5
+ an agent architecture that adds explicit self-reflection after task attempts, storing verbal feedback in memory to improve performance on subsequent trials through "verbal reinforcement learning."
6
+
7
+ ## .why
8
+
9
+ reflexion addresses a key limitation of single-attempt agents: they cannot learn from their mistakes within a session. by reflecting on failures and storing insights, the agent can iteratively improve without weight updates. this enables rapid adaptation and higher eventual success rates.
10
+
11
+ ## dependsOn
12
+
13
+ - `agentic-loop` — base execution pattern
14
+ - `reasoning-trace` — reflection is a form of reasoning
15
+ - `context-window` — stores reflection memory
16
+
17
+ ## pattern structure
18
+
19
+ ```
20
+ Attempt 1:
21
+ [Execute task]
22
+ Result: Failed (test case 3)
23
+
24
+ Reflection:
25
+ "I failed because I didn't handle the edge case where
26
+ the input is empty. Next time I should check for
27
+ empty inputs before processing."
28
+
29
+ Attempt 2:
30
+ [Execute task with reflection in context]
31
+ Result: Passed
32
+ ```
33
+
34
+ ## key components
35
+
36
+ | component | purpose |
37
+ |-----------|---------|
38
+ | actor | executes actions in environment |
39
+ | evaluator | scores trajectory (success/failure) |
40
+ | self-reflection | generates verbal feedback |
41
+ | memory | stores reflections for future attempts |
42
+
43
+ ## benchmark performance
44
+
45
+ | benchmark | improvement |
46
+ |-----------|-------------|
47
+ | ALFWorld | +22% success rate with reflection |
48
+ | HotPotQA | improved accuracy over baseline ReAct |
49
+ | programming | higher pass rates on iterative debugging |
50
+
51
+ ## vs other patterns
52
+
53
+ | pattern | learns from failure? | mechanism |
54
+ |---------|---------------------|-----------|
55
+ | ReAct | no | single attempt |
56
+ | Reflexion | yes | verbal memory |
57
+ | LATS | yes | tree search with backtracking |
58
+
59
+ ## implementation notes
60
+
61
+ - reflection is stored as text in context or external memory
62
+ - number of attempts typically capped (e.g., 3-5)
63
+ - works best when failure modes are diverse
64
+
65
+ ## sources
66
+
67
+ - [Reflexion: Language Agents with Verbal Reinforcement Learning](https://arxiv.org/abs/2303.11366) — original paper
68
+ - [AgentBench](https://arxiv.org/abs/2308.03688) — benchmark including reflexion variants
@@ -0,0 +1,76 @@
1
+ # tree-of-thoughts
2
+
3
+ ## .what
4
+
5
+ a deliberate problem-solving framework that explores multiple reasoning paths as a tree structure, using search algorithms (BFS/DFS) and evaluation to find optimal solutions.
6
+
7
+ ## .why
8
+
9
+ tree of thoughts addresses the limitation of linear chain-of-thought: once a reasoning path is taken, there's no backtracking. by explicitly exploring multiple branches and evaluating intermediate states, ToT enables deliberate planning and can solve problems requiring lookahead that linear approaches cannot.
10
+
11
+ ## dependsOn
12
+
13
+ - `reasoning-trace` — each node contains reasoning
14
+ - `llm` — generates and evaluates thoughts
15
+
16
+ ## pattern structure
17
+
18
+ ```
19
+ [Problem]
20
+
21
+ ┌────────────┼────────────┐
22
+ │ │ │
23
+ [Thought A] [Thought B] [Thought C]
24
+ │ │ │
25
+ [eval: 0.8] [eval: 0.3] [eval: 0.9] ← best
26
+ │ │
27
+ [Thought A1] [Thought C1]
28
+ │ │
29
+ [eval: 0.6] [eval: 0.95] ← selected
30
+ ```
31
+
32
+ ## key components
33
+
34
+ | component | purpose |
35
+ |-----------|---------|
36
+ | thought decomposition | break problem into steps |
37
+ | thought generator | propose multiple candidates |
38
+ | state evaluator | score intermediate states |
39
+ | search algorithm | BFS, DFS, or beam search |
40
+
41
+ ## benchmark performance
42
+
43
+ | benchmark | ToT vs CoT |
44
+ |-----------|------------|
45
+ | Game of 24 | 74% vs 4% |
46
+ | Creative Writing | improved coherence |
47
+ | Crosswords | significantly higher solve rate |
48
+
49
+ ## search strategies
50
+
51
+ | strategy | characteristic |
52
+ |----------|----------------|
53
+ | BFS | explore all options at each depth |
54
+ | DFS | explore deeply first, backtrack |
55
+ | beam search | keep top-k candidates at each level |
56
+
57
+ ## cost tradeoff
58
+
59
+ ToT requires significantly more LLM calls than linear approaches:
60
+ - multiple thought proposals per step
61
+ - evaluation calls for each candidate
62
+ - may explore many branches
63
+
64
+ ## vs other patterns
65
+
66
+ | pattern | exploration | backtracking |
67
+ |---------|-------------|--------------|
68
+ | CoT | linear | none |
69
+ | Self-Consistency | parallel paths, no interaction | none |
70
+ | ToT | tree structure | yes |
71
+ | LATS | tree + MCTS | yes, with learning |
72
+
73
+ ## sources
74
+
75
+ - [Tree of Thoughts: Deliberate Problem Solving](https://arxiv.org/abs/2305.10601) — original paper (NeurIPS 2023)
76
+ - [CoALA](https://arxiv.org/abs/2309.02427) — positions ToT in agent framework
@@ -0,0 +1,73 @@
1
+ # self-consistency
2
+
3
+ ## .what
4
+
5
+ a decoding strategy that samples multiple reasoning paths from the llm and selects the final answer by majority vote, leveraging the intuition that correct reasoning is more likely to converge on the same answer.
6
+
7
+ ## .why
8
+
9
+ self-consistency exploits the stochastic nature of llm generation as a feature rather than a bug. different reasoning paths may make different mistakes, but correct paths tend to agree on the final answer. by sampling multiple times and voting, we reduce the impact of individual reasoning errors.
10
+
11
+ ## dependsOn
12
+
13
+ - `reasoning-trace` — each sample produces a trace
14
+ - `llm` — generates multiple samples
15
+
16
+ ## pattern structure
17
+
18
+ ```
19
+ Question: What is the capital of Australia?
20
+
21
+ Sample 1: "Australia is in Oceania. Sydney is the largest city.
22
+ But the capital is Canberra." → Canberra
23
+
24
+ Sample 2: "Australia's government is in Canberra, which was
25
+ purpose-built as the capital." → Canberra
26
+
27
+ Sample 3: "The largest city is Sydney, which might be the
28
+ capital." → Sydney
29
+
30
+ Majority vote: Canberra (2/3)
31
+ Final answer: Canberra
32
+ ```
33
+
34
+ ## key characteristics
35
+
36
+ - **embarrassingly parallel**: all samples independent
37
+ - **temperature > 0**: requires stochastic sampling
38
+ - **answer extraction**: must identify final answer in each trace
39
+ - **voting mechanism**: typically majority, can be weighted
40
+
41
+ ## benchmark performance
42
+
43
+ | benchmark | improvement over greedy CoT |
44
+ |-----------|---------------------------|
45
+ | arithmetic | +17.9% (GSM8K) |
46
+ | commonsense | +11.0% (CommonsenseQA) |
47
+ | symbolic | significant gains |
48
+
49
+ ## parameters
50
+
51
+ | parameter | effect |
52
+ |-----------|--------|
53
+ | num_samples | more samples = higher accuracy, higher cost |
54
+ | temperature | higher = more diverse samples |
55
+ | voting method | majority, weighted, etc. |
56
+
57
+ ## cost analysis
58
+
59
+ self-consistency is more expensive than single-path CoT:
60
+ - linear cost increase with sample count
61
+ - typically 5-40 samples used
62
+ - parallelizable (latency ≈ single sample if concurrent)
63
+
64
+ ## limitations
65
+
66
+ - requires extractable final answers
67
+ - expensive for long generations
68
+ - doesn't help if all paths fail similarly
69
+
70
+ ## sources
71
+
72
+ - [Self-Consistency Improves Chain of Thought Reasoning](https://arxiv.org/abs/2203.11171) — original paper
73
+ - [Reasoning with LM Prompting Survey](https://github.com/zjunlp/Prompt4ReasoningPapers) — comparison with other methods
@@ -0,0 +1,78 @@
1
+ # lats-pattern (language agent tree search)
2
+
3
+ ## .what
4
+
5
+ an advanced agent framework that combines tree-of-thoughts with monte carlo tree search (MCTS), using external feedback and learned value functions to guide exploration of action sequences.
6
+
7
+ ## .why
8
+
9
+ LATS addresses limitations of both linear agents (no backtracking) and static tree search (no learning). by incorporating MCTS principles — selection, expansion, simulation, backpropagation — LATS can learn from failed trajectories and allocate search effort efficiently toward promising paths.
10
+
11
+ ## dependsOn
12
+
13
+ - `tree-of-thoughts` — tree structure for exploration
14
+ - `agentic-loop` — action execution
15
+ - `reflexion-pattern` — learning from feedback
16
+
17
+ ## mcts components in LATS
18
+
19
+ | component | implementation |
20
+ |-----------|----------------|
21
+ | selection | UCB1-guided node choice |
22
+ | expansion | llm generates candidate actions |
23
+ | simulation | execute action, observe result |
24
+ | backpropagation | update values based on outcome |
25
+
26
+ ## pattern structure
27
+
28
+ ```
29
+ [Root State]
30
+
31
+ ┌────────┼────────┐
32
+ │ │ │
33
+ [A:0.6] [B:0.8] [C:0.4] ← UCB1 selects B
34
+
35
+ ┌────────┼────────┐
36
+ │ │ │
37
+ [B1:0.7] [B2:0.9] [B3:0.5] ← expand B, simulate
38
+
39
+ [success]
40
+
41
+ backpropagate +reward
42
+ ```
43
+
44
+ ## benchmark performance
45
+
46
+ | benchmark | LATS performance |
47
+ |-----------|-----------------|
48
+ | HotPotQA | state-of-the-art among agent methods |
49
+ | WebShop | improved over ReAct/Reflexion |
50
+ | Programming | higher solve rates with search |
51
+
52
+ ## key innovations over ToT
53
+
54
+ | aspect | ToT | LATS |
55
+ |--------|-----|------|
56
+ | exploration | static heuristic | learned UCB1 |
57
+ | feedback | evaluation only | environment + reflection |
58
+ | memory | none | experience buffer |
59
+ | replanning | from scratch | informed by history |
60
+
61
+ ## computational cost
62
+
63
+ LATS is more expensive than simpler methods:
64
+ - multiple simulation trajectories
65
+ - value function updates
66
+ - but more sample-efficient than random exploration
67
+
68
+ ## when to use
69
+
70
+ - complex multi-step tasks
71
+ - sparse reward signals
72
+ - when backtracking is valuable
73
+ - sufficient compute budget
74
+
75
+ ## sources
76
+
77
+ - [Language Agent Tree Search (LATS)](https://arxiv.org/abs/2310.04406) — original paper (ICML 2024)
78
+ - [Understanding LLM Agent Planning Survey](https://arxiv.org/abs/2402.02716) — positions LATS in taxonomy