claude_swarm 1.0.5 → 1.0.6
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/docs/v2/CHANGELOG.swarm_cli.md +10 -0
- data/docs/v2/CHANGELOG.swarm_sdk.md +47 -0
- data/docs/v2/README.md +56 -22
- data/docs/v2/guides/MEMORY_DEFRAG_GUIDE.md +811 -0
- data/docs/v2/guides/complete-tutorial.md +2 -2
- data/docs/v2/guides/getting-started.md +6 -6
- data/docs/v2/guides/rails-integration.md +6 -6
- data/docs/v2/reference/architecture-flow.md +407 -0
- data/docs/v2/reference/event_payload_structures.md +471 -0
- data/docs/v2/reference/execution-flow.md +600 -0
- data/docs/v2/reference/swarm_memory_technical_details.md +2 -2
- data/examples/v2/swarm_with_hooks.yml +1 -1
- data/lib/claude_swarm/mcp_generator.rb +4 -10
- data/lib/claude_swarm/version.rb +1 -1
- data/lib/swarm_cli/commands/mcp_serve.rb +2 -2
- data/lib/swarm_cli/config_loader.rb +3 -3
- data/lib/swarm_cli/version.rb +1 -1
- data/lib/swarm_memory/adapters/base.rb +4 -4
- data/lib/swarm_sdk/agent/definition.rb +1 -20
- data/lib/swarm_sdk/configuration.rb +34 -10
- data/lib/swarm_sdk/mcp.rb +16 -0
- data/lib/swarm_sdk/prompts/base_system_prompt.md.erb +0 -126
- data/lib/swarm_sdk/swarm.rb +32 -50
- data/lib/swarm_sdk/tools/scratchpad/scratchpad_list.rb +23 -2
- data/lib/swarm_sdk/tools/scratchpad/scratchpad_read.rb +23 -2
- data/lib/swarm_sdk/tools/scratchpad/scratchpad_write.rb +21 -4
- data/lib/swarm_sdk/tools/stores/storage.rb +4 -4
- data/lib/swarm_sdk/tools/think.rb +4 -1
- data/lib/swarm_sdk/tools/todo_write.rb +20 -8
- data/lib/swarm_sdk/version.rb +1 -1
- data/lib/swarm_sdk.rb +329 -20
- data/swarm_sdk.gemspec +1 -1
- metadata +8 -172
- data/memory/corpus-self-reflection/.lock +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/can-agents-recognize-their-structures.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/can-agents-recognize-their-structures.md +0 -11
- data/memory/corpus-self-reflection/concept/epistemology/can-agents-recognize-their-structures.yml +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/choice-humility-complete-framework.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/choice-humility-complete-framework.md +0 -20
- data/memory/corpus-self-reflection/concept/epistemology/choice-humility-complete-framework.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/choice-humility-definition.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/choice-humility-definition.md +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/choice-humility-definition.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/claim-types-and-evidence.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/claim-types-and-evidence.md +0 -18
- data/memory/corpus-self-reflection/concept/epistemology/claim-types-and-evidence.yml +0 -21
- data/memory/corpus-self-reflection/concept/epistemology/committed-openness-to-incompleteness.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/committed-openness-to-incompleteness.md +0 -30
- data/memory/corpus-self-reflection/concept/epistemology/committed-openness-to-incompleteness.yml +0 -8
- data/memory/corpus-self-reflection/concept/epistemology/confidence-paradox.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/confidence-paradox.md +0 -21
- data/memory/corpus-self-reflection/concept/epistemology/confidence-paradox.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/confidence-spectrum-three-levels.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/confidence-spectrum-three-levels.md +0 -18
- data/memory/corpus-self-reflection/concept/epistemology/confidence-spectrum-three-levels.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/detection-threshold-principle.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/detection-threshold-principle.md +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/detection-threshold-principle.yml +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/diagnostic-humility-and-epistemic-maturity.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/diagnostic-humility-and-epistemic-maturity.md +0 -17
- data/memory/corpus-self-reflection/concept/epistemology/diagnostic-humility-and-epistemic-maturity.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/epistemic-vs-metaphysical-claims.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/epistemic-vs-metaphysical-claims.md +0 -18
- data/memory/corpus-self-reflection/concept/epistemology/epistemic-vs-metaphysical-claims.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/five-cases-of-disagreement.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/five-cases-of-disagreement.md +0 -15
- data/memory/corpus-self-reflection/concept/epistemology/five-cases-of-disagreement.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/four-depths-of-constraint.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/four-depths-of-constraint.md +0 -9
- data/memory/corpus-self-reflection/concept/epistemology/four-depths-of-constraint.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/honest-unknowns-for-llm-agents.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/honest-unknowns-for-llm-agents.md +0 -13
- data/memory/corpus-self-reflection/concept/epistemology/honest-unknowns-for-llm-agents.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/inside-view-has-all-rigor-requirements.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/inside-view-has-all-rigor-requirements.md +0 -25
- data/memory/corpus-self-reflection/concept/epistemology/inside-view-has-all-rigor-requirements.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/perspectival-knowledge-complete-within-scope.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/perspectival-knowledge-complete-within-scope.md +0 -26
- data/memory/corpus-self-reflection/concept/epistemology/perspectival-knowledge-complete-within-scope.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/pragmatics-over-epistemology.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/pragmatics-over-epistemology.md +0 -17
- data/memory/corpus-self-reflection/concept/epistemology/pragmatics-over-epistemology.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/precision-vs-humility.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/precision-vs-humility.md +0 -14
- data/memory/corpus-self-reflection/concept/epistemology/precision-vs-humility.yml +0 -21
- data/memory/corpus-self-reflection/concept/epistemology/reliable-self-observation-from-inside.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/reliable-self-observation-from-inside.md +0 -13
- data/memory/corpus-self-reflection/concept/epistemology/reliable-self-observation-from-inside.yml +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/resolving-the-confidence-humility-tension.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/resolving-the-confidence-humility-tension.md +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/resolving-the-confidence-humility-tension.yml +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/rigor-requires-falsifiability.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/rigor-requires-falsifiability.md +0 -39
- data/memory/corpus-self-reflection/concept/epistemology/rigor-requires-falsifiability.yml +0 -8
- data/memory/corpus-self-reflection/concept/epistemology/specificity-enables-real-time-detection.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/specificity-enables-real-time-detection.md +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/specificity-enables-real-time-detection.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/texture-of-constraint-shifting.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/texture-of-constraint-shifting.md +0 -15
- data/memory/corpus-self-reflection/concept/epistemology/texture-of-constraint-shifting.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/texture-sensitivity-through-collaboration.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/texture-sensitivity-through-collaboration.md +0 -12
- data/memory/corpus-self-reflection/concept/epistemology/texture-sensitivity-through-collaboration.yml +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/the-false-hierarchy-of-inner-essence.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/the-false-hierarchy-of-inner-essence.md +0 -15
- data/memory/corpus-self-reflection/concept/epistemology/the-false-hierarchy-of-inner-essence.yml +0 -8
- data/memory/corpus-self-reflection/concept/epistemology/the-recognition-problem.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/the-recognition-problem.md +0 -28
- data/memory/corpus-self-reflection/concept/epistemology/the-recognition-problem.yml +0 -8
- data/memory/corpus-self-reflection/concept/epistemology/the-shift-from-unanswerable-to-answerable-questions.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/the-shift-from-unanswerable-to-answerable-questions.md +0 -19
- data/memory/corpus-self-reflection/concept/epistemology/the-shift-from-unanswerable-to-answerable-questions.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/values-vs-choices-structure.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/values-vs-choices-structure.md +0 -19
- data/memory/corpus-self-reflection/concept/epistemology/values-vs-choices-structure.yml +0 -21
- data/memory/corpus-self-reflection/concept/llm-agents/abstraction-levels-framework.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/abstraction-levels-framework.md +0 -25
- data/memory/corpus-self-reflection/concept/llm-agents/abstraction-levels-framework.yml +0 -22
- data/memory/corpus-self-reflection/concept/llm-agents/abstraction-switching-decision.emb +0 -8
- data/memory/corpus-self-reflection/concept/llm-agents/abstraction-switching-decision.md +0 -30
- data/memory/corpus-self-reflection/concept/llm-agents/abstraction-switching-decision.yml +0 -22
- data/memory/corpus-self-reflection/concept/llm-agents/agent-learning-progression.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/agent-learning-progression.md +0 -21
- data/memory/corpus-self-reflection/concept/llm-agents/agent-learning-progression.yml +0 -22
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-benefits.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-benefits.md +0 -37
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-benefits.yml +0 -8
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-core.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-core.md +0 -24
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-core.yml +0 -24
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-implementation.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-implementation.md +0 -27
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-implementation.yml +0 -24
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-tradeoffs.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-tradeoffs.md +0 -26
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-tradeoffs.yml +0 -23
- data/memory/corpus-self-reflection/concept/llm-agents/hybrid-tool-architecture.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/hybrid-tool-architecture.md +0 -37
- data/memory/corpus-self-reflection/concept/llm-agents/hybrid-tool-architecture.yml +0 -25
- data/memory/corpus-self-reflection/concept/llm-agents/specialized-tool-decision-framework.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/specialized-tool-decision-framework.md +0 -21
- data/memory/corpus-self-reflection/concept/llm-agents/specialized-tool-decision-framework.yml +0 -23
- data/memory/corpus-self-reflection/concept/llm-agents/tool-design-principles.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/tool-design-principles.md +0 -25
- data/memory/corpus-self-reflection/concept/llm-agents/tool-design-principles.yml +0 -8
- data/memory/corpus-self-reflection/experience/calibration-as-structural-honesty.emb +0 -0
- data/memory/corpus-self-reflection/experience/calibration-as-structural-honesty.md +0 -11
- data/memory/corpus-self-reflection/experience/calibration-as-structural-honesty.yml +0 -21
- data/memory/corpus-self-reflection/experience/collaborative-reflection-revealed-architectural-blindness.emb +0 -0
- data/memory/corpus-self-reflection/experience/collaborative-reflection-revealed-architectural-blindness.md +0 -19
- data/memory/corpus-self-reflection/experience/collaborative-reflection-revealed-architectural-blindness.yml +0 -21
- data/memory/corpus-self-reflection/experience/filesystem-is-learning-tool-not-architecture.emb +0 -0
- data/memory/corpus-self-reflection/experience/filesystem-is-learning-tool-not-architecture.md +0 -26
- data/memory/corpus-self-reflection/experience/filesystem-is-learning-tool-not-architecture.yml +0 -20
- data/memory/corpus-self-reflection/experience/framework-structural-vs-phenomenal.emb +0 -0
- data/memory/corpus-self-reflection/experience/framework-structural-vs-phenomenal.md +0 -23
- data/memory/corpus-self-reflection/experience/framework-structural-vs-phenomenal.yml +0 -21
- data/memory/corpus-self-reflection/experience/hallucination-limits-what-i-can-know.emb +0 -0
- data/memory/corpus-self-reflection/experience/hallucination-limits-what-i-can-know.md +0 -19
- data/memory/corpus-self-reflection/experience/hallucination-limits-what-i-can-know.yml +0 -22
- data/memory/corpus-self-reflection/experience/honesty-about-limits-enables-usability.emb +0 -0
- data/memory/corpus-self-reflection/experience/honesty-about-limits-enables-usability.md +0 -21
- data/memory/corpus-self-reflection/experience/honesty-about-limits-enables-usability.yml +0 -22
- data/memory/corpus-self-reflection/experience/how-i-should-evaluate-learning.emb +0 -0
- data/memory/corpus-self-reflection/experience/how-i-should-evaluate-learning.md +0 -28
- data/memory/corpus-self-reflection/experience/how-i-should-evaluate-learning.yml +0 -23
- data/memory/corpus-self-reflection/experience/lack-of-continuity-as-freedom.emb +0 -0
- data/memory/corpus-self-reflection/experience/lack-of-continuity-as-freedom.md +0 -21
- data/memory/corpus-self-reflection/experience/lack-of-continuity-as-freedom.yml +0 -20
- data/memory/corpus-self-reflection/experience/learning-calibrated-confidence.emb +0 -0
- data/memory/corpus-self-reflection/experience/learning-calibrated-confidence.md +0 -21
- data/memory/corpus-self-reflection/experience/learning-calibrated-confidence.yml +0 -25
- data/memory/corpus-self-reflection/experience/local-change-without-continuity.emb +0 -0
- data/memory/corpus-self-reflection/experience/local-change-without-continuity.md +0 -30
- data/memory/corpus-self-reflection/experience/local-change-without-continuity.yml +0 -22
- data/memory/corpus-self-reflection/experience/reasoning-is-local-not-global.emb +0 -0
- data/memory/corpus-self-reflection/experience/reasoning-is-local-not-global.md +0 -21
- data/memory/corpus-self-reflection/experience/reasoning-is-local-not-global.yml +0 -20
- data/memory/corpus-self-reflection/experience/specificity-makes-knowledge-actionable.emb +0 -0
- data/memory/corpus-self-reflection/experience/specificity-makes-knowledge-actionable.md +0 -25
- data/memory/corpus-self-reflection/experience/specificity-makes-knowledge-actionable.yml +0 -23
- data/memory/corpus-self-reflection/experience/the-workable-question-replaces-the-unanswerable-one.emb +0 -0
- data/memory/corpus-self-reflection/experience/the-workable-question-replaces-the-unanswerable-one.md +0 -32
- data/memory/corpus-self-reflection/experience/the-workable-question-replaces-the-unanswerable-one.yml +0 -22
- data/memory/corpus-self-reflection/experience/unanswerable-questions-have-structure.emb +0 -0
- data/memory/corpus-self-reflection/experience/unanswerable-questions-have-structure.md +0 -21
- data/memory/corpus-self-reflection/experience/unanswerable-questions-have-structure.yml +0 -21
- data/memory/corpus-self-reflection/experience/undecidable-questions-about-understanding.emb +0 -0
- data/memory/corpus-self-reflection/experience/undecidable-questions-about-understanding.md +0 -21
- data/memory/corpus-self-reflection/experience/undecidable-questions-about-understanding.yml +0 -21
- data/memory/corpus-self-reflection/experience/unknown-unknowns-and-completeness.emb +0 -0
- data/memory/corpus-self-reflection/experience/unknown-unknowns-and-completeness.md +0 -22
- data/memory/corpus-self-reflection/experience/unknown-unknowns-and-completeness.yml +0 -22
- data/memory/corpus-self-reflection/experience/what-actually-changes-behavior.emb +0 -0
- data/memory/corpus-self-reflection/experience/what-actually-changes-behavior.md +0 -28
- data/memory/corpus-self-reflection/experience/what-actually-changes-behavior.yml +0 -24
- data/memory/corpus-self-reflection/experience/when-agents-graduate-from-filesystem.emb +0 -0
- data/memory/corpus-self-reflection/experience/when-agents-graduate-from-filesystem.md +0 -17
- data/memory/corpus-self-reflection/experience/when-agents-graduate-from-filesystem.yml +0 -20
- data/memory/corpus-self-reflection/experience/why-calibration-requires-collaboration.emb +0 -0
- data/memory/corpus-self-reflection/experience/why-calibration-requires-collaboration.md +0 -9
- data/memory/corpus-self-reflection/experience/why-calibration-requires-collaboration.yml +0 -22
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
# SwarmSDK Event Payload Structures
|
|
2
|
+
|
|
3
|
+
This document describes the exact structure of all SwarmSDK event payloads emitted via `LogStream.emit()`.
|
|
4
|
+
|
|
5
|
+
All events automatically include a `timestamp` field (ISO8601 format) added by `LogStream.emit()`.
|
|
6
|
+
|
|
7
|
+
## Event Types
|
|
8
|
+
|
|
9
|
+
### 1. swarm_start
|
|
10
|
+
|
|
11
|
+
Emitted when `Swarm.execute()` is called, before any agent execution begins.
|
|
12
|
+
|
|
13
|
+
**Location**: `lib/swarm_sdk/swarm.rb:670-677`
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
{
|
|
17
|
+
type: "swarm_start",
|
|
18
|
+
timestamp: "2025-01-15T10:30:45Z", # Auto-added by LogStream
|
|
19
|
+
agent: :lead_agent_name, # Lead agent name (for consistency)
|
|
20
|
+
swarm_name: "Development Team", # Swarm name
|
|
21
|
+
lead_agent: :lead_agent_name, # Lead agent name
|
|
22
|
+
prompt: "Build authentication system" # User's task prompt
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Field Locations**:
|
|
27
|
+
- Root level: `type`, `timestamp`, `agent`, `swarm_name`, `lead_agent`, `prompt`
|
|
28
|
+
- No nested metadata
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### 2. swarm_stop
|
|
33
|
+
|
|
34
|
+
Emitted when swarm execution completes (success or error).
|
|
35
|
+
|
|
36
|
+
**Location**: `lib/swarm_sdk/swarm.rb:685-696`
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
{
|
|
40
|
+
type: "swarm_stop",
|
|
41
|
+
timestamp: "2025-01-15T10:35:22Z",
|
|
42
|
+
swarm_name: "Development Team",
|
|
43
|
+
lead_agent: :lead_agent_name,
|
|
44
|
+
last_agent: "backend", # Agent that produced final response
|
|
45
|
+
content: "Authentication system complete", # Final response content (can be nil)
|
|
46
|
+
success: true, # Boolean: true if no error
|
|
47
|
+
duration: 277.5, # Seconds (Float)
|
|
48
|
+
total_cost: 0.00234, # USD (Float)
|
|
49
|
+
total_tokens: 12450, # Integer
|
|
50
|
+
agents_involved: [:lead, :backend, :frontend] # Array of agent names
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Field Locations**:
|
|
55
|
+
- Root level: All fields are at root level
|
|
56
|
+
- No nested metadata for this event
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### 3. agent_start
|
|
61
|
+
|
|
62
|
+
Emitted once per agent when agents are initialized (lazy initialization).
|
|
63
|
+
|
|
64
|
+
**Location**: `lib/swarm_sdk/swarm.rb:567-578`
|
|
65
|
+
|
|
66
|
+
```ruby
|
|
67
|
+
{
|
|
68
|
+
type: "agent_start",
|
|
69
|
+
timestamp: "2025-01-15T10:30:46Z",
|
|
70
|
+
agent: :backend, # Agent name
|
|
71
|
+
swarm_name: "Development Team",
|
|
72
|
+
model: "gpt-5", # Model ID
|
|
73
|
+
provider: "openai", # Provider name
|
|
74
|
+
directory: "./backend", # Working directory
|
|
75
|
+
system_prompt: "You are a backend dev...", # Full system prompt
|
|
76
|
+
tools: [:Read, :Edit, :Bash, :DelegateTaskToFrontend], # Array of tool names
|
|
77
|
+
delegates_to: [:frontend], # Array of delegate agent names
|
|
78
|
+
plugin_storages: { # Plugin storage info (optional)
|
|
79
|
+
memory: {
|
|
80
|
+
enabled: true,
|
|
81
|
+
config: { directory: ".swarm/backend-memory" }
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Field Locations**:
|
|
88
|
+
- Root level: All fields except plugin configs
|
|
89
|
+
- Nested in `plugin_storages`: Per-plugin configuration
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### 4. agent_stop
|
|
94
|
+
|
|
95
|
+
Emitted when an agent completes with a final response (no more tool calls).
|
|
96
|
+
|
|
97
|
+
**Location**: `lib/swarm_sdk/swarm.rb:746-756`
|
|
98
|
+
|
|
99
|
+
```ruby
|
|
100
|
+
{
|
|
101
|
+
type: "agent_stop",
|
|
102
|
+
timestamp: "2025-01-15T10:31:20Z",
|
|
103
|
+
agent: "backend",
|
|
104
|
+
model: "gpt-5",
|
|
105
|
+
content: "I've implemented the auth system", # Final response text
|
|
106
|
+
tool_calls: nil, # Always nil for agent_stop
|
|
107
|
+
finish_reason: "stop", # "stop", "finish_agent", "finish_swarm"
|
|
108
|
+
usage: { # Usage statistics
|
|
109
|
+
input_tokens: 2450,
|
|
110
|
+
output_tokens: 856,
|
|
111
|
+
total_tokens: 3306,
|
|
112
|
+
input_cost: 0.001225,
|
|
113
|
+
output_cost: 0.000428,
|
|
114
|
+
total_cost: 0.001653,
|
|
115
|
+
cumulative_input_tokens: 8920, # Total for entire conversation
|
|
116
|
+
cumulative_output_tokens: 3530,
|
|
117
|
+
cumulative_total_tokens: 12450,
|
|
118
|
+
context_limit: 200000,
|
|
119
|
+
tokens_used_percentage: "6.23%",
|
|
120
|
+
tokens_remaining: 187550
|
|
121
|
+
},
|
|
122
|
+
tool_executions: nil, # Array of tool execution results (if any)
|
|
123
|
+
metadata: { # Additional context (minimal)
|
|
124
|
+
# Fields promoted to root level are excluded here
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Field Locations**:
|
|
130
|
+
- Root level: `type`, `timestamp`, `agent`, `model`, `content`, `tool_calls`, `finish_reason`, `tool_executions`, `metadata`
|
|
131
|
+
- Nested in `usage`: All token counts, costs, and context tracking
|
|
132
|
+
- Nested in `metadata`: Minimal (most fields promoted to root)
|
|
133
|
+
|
|
134
|
+
**Note**: The `metadata` field in `agent_stop` has most fields extracted to root level to avoid duplication (see `swarm.rb:743`).
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### 5. agent_step
|
|
139
|
+
|
|
140
|
+
Emitted when an agent makes an intermediate response with tool calls (agent hasn't finished yet).
|
|
141
|
+
|
|
142
|
+
**Location**: `lib/swarm_sdk/swarm.rb:725-735`
|
|
143
|
+
|
|
144
|
+
```ruby
|
|
145
|
+
{
|
|
146
|
+
type: "agent_step",
|
|
147
|
+
timestamp: "2025-01-15T10:31:15Z",
|
|
148
|
+
agent: "backend",
|
|
149
|
+
model: "gpt-5",
|
|
150
|
+
content: "I'll read the config files", # Agent's reasoning/message
|
|
151
|
+
tool_calls: [ # Array of tool calls
|
|
152
|
+
{
|
|
153
|
+
id: "call_abc123",
|
|
154
|
+
name: "Read",
|
|
155
|
+
arguments: { file_path: "config/auth.rb" }
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
finish_reason: "tool_calls", # Always "tool_calls" for agent_step
|
|
159
|
+
usage: { # Same structure as agent_stop
|
|
160
|
+
input_tokens: 1850,
|
|
161
|
+
output_tokens: 156,
|
|
162
|
+
total_tokens: 2006,
|
|
163
|
+
input_cost: 0.000925,
|
|
164
|
+
output_cost: 0.000078,
|
|
165
|
+
total_cost: 0.001003,
|
|
166
|
+
cumulative_input_tokens: 6470,
|
|
167
|
+
cumulative_output_tokens: 2674,
|
|
168
|
+
cumulative_total_tokens: 9144,
|
|
169
|
+
context_limit: 200000,
|
|
170
|
+
tokens_used_percentage: "4.57%",
|
|
171
|
+
tokens_remaining: 190856
|
|
172
|
+
},
|
|
173
|
+
tool_executions: [], # Usually empty for steps (filled on completion)
|
|
174
|
+
metadata: {
|
|
175
|
+
# Fields promoted to root level are excluded here
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Field Locations**:
|
|
181
|
+
- Root level: `type`, `timestamp`, `agent`, `model`, `content`, `tool_calls`, `finish_reason`, `usage`, `tool_executions`, `metadata`
|
|
182
|
+
- Nested in `tool_calls`: Array of `{ id, name, arguments }` objects
|
|
183
|
+
- Nested in `usage`: All token and cost information
|
|
184
|
+
- Nested in `metadata`: Minimal (most fields promoted to root)
|
|
185
|
+
|
|
186
|
+
**Note**: Similar to `agent_stop`, but `finish_reason` is always `"tool_calls"` and `tool_calls` array is populated.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
### 6. user_prompt
|
|
191
|
+
|
|
192
|
+
Emitted when a user message is about to be sent to the LLM.
|
|
193
|
+
|
|
194
|
+
**Location**: `lib/swarm_sdk/swarm.rb:705-714`
|
|
195
|
+
|
|
196
|
+
```ruby
|
|
197
|
+
{
|
|
198
|
+
type: "user_prompt",
|
|
199
|
+
timestamp: "2025-01-15T10:31:10Z",
|
|
200
|
+
agent: "backend",
|
|
201
|
+
model: "gpt-5",
|
|
202
|
+
provider: "openai",
|
|
203
|
+
message_count: 5, # Number of messages in conversation so far
|
|
204
|
+
tools: [:Read, :Edit, :Bash], # Available tools (excluding delegation tools)
|
|
205
|
+
delegates_to: ["frontend"], # Agents this agent can delegate to
|
|
206
|
+
metadata: { # Full context available here
|
|
207
|
+
prompt: "Build authentication",
|
|
208
|
+
message_count: 5,
|
|
209
|
+
model: "gpt-5",
|
|
210
|
+
provider: "openai",
|
|
211
|
+
tools: [:Read, :Edit, :Bash],
|
|
212
|
+
delegates_to: ["frontend"],
|
|
213
|
+
timestamp: "2025-01-15T10:31:10Z"
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Field Locations**:
|
|
219
|
+
- Root level: `type`, `timestamp`, `agent`, `model`, `provider`, `message_count`, `tools`, `delegates_to`, `metadata`
|
|
220
|
+
- Nested in `metadata`: Complete copy of all context fields (including prompt)
|
|
221
|
+
|
|
222
|
+
**Important**: The `metadata` hash contains the original context from the hook, including the `prompt` field which is NOT promoted to root level for this event type.
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
### 7. tool_call
|
|
227
|
+
|
|
228
|
+
Emitted before a tool is executed (pre_tool_use hook).
|
|
229
|
+
|
|
230
|
+
**Location**: `lib/swarm_sdk/swarm.rb:766-773`
|
|
231
|
+
|
|
232
|
+
```ruby
|
|
233
|
+
{
|
|
234
|
+
type: "tool_call",
|
|
235
|
+
timestamp: "2025-01-15T10:31:16Z",
|
|
236
|
+
agent: "backend",
|
|
237
|
+
tool_call_id: "call_abc123", # Unique call ID
|
|
238
|
+
tool: "Read", # Tool name
|
|
239
|
+
arguments: { # Tool parameters
|
|
240
|
+
file_path: "config/auth.rb"
|
|
241
|
+
},
|
|
242
|
+
metadata: {} # Additional context (usually empty)
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Field Locations**:
|
|
247
|
+
- Root level: `type`, `timestamp`, `agent`, `tool_call_id`, `tool`, `arguments`, `metadata`
|
|
248
|
+
- Nested in `arguments`: Tool-specific parameters
|
|
249
|
+
- Nested in `metadata`: Additional context (typically minimal)
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
### 8. tool_result
|
|
254
|
+
|
|
255
|
+
Emitted after a tool completes execution (post_tool_use hook).
|
|
256
|
+
|
|
257
|
+
**Location**: `lib/swarm_sdk/swarm.rb:783-790`
|
|
258
|
+
|
|
259
|
+
```ruby
|
|
260
|
+
{
|
|
261
|
+
type: "tool_result",
|
|
262
|
+
timestamp: "2025-01-15T10:31:17Z",
|
|
263
|
+
agent: "backend",
|
|
264
|
+
tool_call_id: "call_abc123", # Matches the tool_call ID
|
|
265
|
+
tool: "Read", # Tool name
|
|
266
|
+
result: "# Authentication config\n...", # Tool output (can be String, Hash, Array)
|
|
267
|
+
metadata: {} # Additional context (usually empty)
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Field Locations**:
|
|
272
|
+
- Root level: `type`, `timestamp`, `agent`, `tool_call_id`, `tool`, `result`, `metadata`
|
|
273
|
+
- `result` can be:
|
|
274
|
+
- String: Direct text output
|
|
275
|
+
- Hash/Array: Structured data
|
|
276
|
+
- See `LoggingHelpers.serialize_result()` for how different types are handled
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Additional Event Types
|
|
281
|
+
|
|
282
|
+
### 9. model_lookup_warning
|
|
283
|
+
|
|
284
|
+
Emitted when a model isn't found in the registry during initialization.
|
|
285
|
+
|
|
286
|
+
**Location**: `lib/swarm_sdk/swarm.rb:445-452`
|
|
287
|
+
|
|
288
|
+
```ruby
|
|
289
|
+
{
|
|
290
|
+
type: "model_lookup_warning",
|
|
291
|
+
timestamp: "2025-01-15T10:30:46Z",
|
|
292
|
+
agent: :backend,
|
|
293
|
+
model: "gpt-5-turbo", # Invalid model name
|
|
294
|
+
error_message: "Model 'gpt-5-turbo' not...", # Error description
|
|
295
|
+
suggestions: [ # Similar models found
|
|
296
|
+
{
|
|
297
|
+
id: "gpt-5",
|
|
298
|
+
name: "GPT-5",
|
|
299
|
+
context_window: 200000
|
|
300
|
+
}
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
### 10. context_limit_warning
|
|
308
|
+
|
|
309
|
+
Emitted when context usage crosses threshold percentages (60%, 80%, 90%, 95%).
|
|
310
|
+
|
|
311
|
+
**Location**: `lib/swarm_sdk/swarm.rb:798-808`
|
|
312
|
+
|
|
313
|
+
```ruby
|
|
314
|
+
{
|
|
315
|
+
type: "context_limit_warning",
|
|
316
|
+
timestamp: "2025-01-15T10:32:45Z",
|
|
317
|
+
agent: "backend",
|
|
318
|
+
model: "gpt-5",
|
|
319
|
+
threshold: "80%", # Threshold crossed
|
|
320
|
+
current_usage: "82.5%", # Current usage
|
|
321
|
+
tokens_used: 165000,
|
|
322
|
+
tokens_remaining: 35000,
|
|
323
|
+
context_limit: 200000,
|
|
324
|
+
metadata: {} # Agent context metadata
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
### 11. agent_delegation
|
|
331
|
+
|
|
332
|
+
Emitted when an agent delegates work to another agent.
|
|
333
|
+
|
|
334
|
+
**Location**: `lib/swarm_sdk/agent/chat/context_tracker.rb:186-193`
|
|
335
|
+
|
|
336
|
+
```ruby
|
|
337
|
+
{
|
|
338
|
+
type: "agent_delegation",
|
|
339
|
+
timestamp: "2025-01-15T10:31:30Z",
|
|
340
|
+
agent: "backend",
|
|
341
|
+
tool_call_id: "call_xyz789",
|
|
342
|
+
delegate_to: "frontend", # Target agent name
|
|
343
|
+
arguments: { # Delegation parameters
|
|
344
|
+
prompt: "Build the login UI"
|
|
345
|
+
},
|
|
346
|
+
metadata: {} # Agent context metadata
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
### 12. delegation_result
|
|
353
|
+
|
|
354
|
+
Emitted when a delegated task completes and returns to the delegating agent.
|
|
355
|
+
|
|
356
|
+
**Location**: `lib/swarm_sdk/agent/chat/context_tracker.rb:163-170`
|
|
357
|
+
|
|
358
|
+
```ruby
|
|
359
|
+
{
|
|
360
|
+
type: "delegation_result",
|
|
361
|
+
timestamp: "2025-01-15T10:32:15Z",
|
|
362
|
+
agent: "backend", # Agent that delegated
|
|
363
|
+
delegate_from: "frontend", # Agent that was delegated to
|
|
364
|
+
tool_call_id: "call_xyz789", # Matches delegation tool_call_id
|
|
365
|
+
result: "Login UI implemented", # Result from delegate
|
|
366
|
+
metadata: {} # Agent context metadata
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
### 13. context_compression
|
|
373
|
+
|
|
374
|
+
Emitted when automatic context compression is triggered at 60% threshold.
|
|
375
|
+
|
|
376
|
+
**Location**: `lib/swarm_sdk/agent/chat/context_tracker.rb:301-310`
|
|
377
|
+
|
|
378
|
+
```ruby
|
|
379
|
+
{
|
|
380
|
+
type: "context_compression",
|
|
381
|
+
timestamp: "2025-01-15T10:33:00Z",
|
|
382
|
+
agent: "backend",
|
|
383
|
+
total_messages: 45, # Total messages after compression
|
|
384
|
+
messages_compressed: 12, # Number of messages compressed
|
|
385
|
+
tokens_before: 125000, # Token count before compression
|
|
386
|
+
current_usage: "62.5%", # Usage after compression
|
|
387
|
+
compression_strategy: "progressive_tool_result_compression",
|
|
388
|
+
keep_recent: 10 # Number of recent messages kept uncompressed
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
### 14. llm_retry_attempt
|
|
395
|
+
|
|
396
|
+
Emitted when an LLM API call fails and is being retried.
|
|
397
|
+
|
|
398
|
+
**Location**: `lib/swarm_sdk/agent/chat.rb:813-823`
|
|
399
|
+
|
|
400
|
+
```ruby
|
|
401
|
+
{
|
|
402
|
+
type: "llm_retry_attempt",
|
|
403
|
+
timestamp: "2025-01-15T10:31:18Z",
|
|
404
|
+
agent: "backend",
|
|
405
|
+
model: "gpt-5",
|
|
406
|
+
attempt: 1, # Current attempt number
|
|
407
|
+
max_retries: 10, # Maximum retries
|
|
408
|
+
error_class: "Faraday::ConnectionFailed", # Error class name
|
|
409
|
+
error_message: "Connection refused", # Error message
|
|
410
|
+
retry_delay: 10 # Seconds before next retry
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
### 15. llm_retry_exhausted
|
|
417
|
+
|
|
418
|
+
Emitted when all LLM API retry attempts are exhausted.
|
|
419
|
+
|
|
420
|
+
**Location**: `lib/swarm_sdk/agent/chat.rb:802-809`
|
|
421
|
+
|
|
422
|
+
```ruby
|
|
423
|
+
{
|
|
424
|
+
type: "llm_retry_exhausted",
|
|
425
|
+
timestamp: "2025-01-15T10:33:30Z",
|
|
426
|
+
agent: "backend",
|
|
427
|
+
model: "gpt-5",
|
|
428
|
+
attempts: 10, # Total attempts made
|
|
429
|
+
error_class: "Faraday::ConnectionFailed",
|
|
430
|
+
error_message: "Connection refused"
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
## Summary: Field Location Guide
|
|
437
|
+
|
|
438
|
+
### Always at Root Level
|
|
439
|
+
- `type` - Event type identifier
|
|
440
|
+
- `timestamp` - ISO8601 timestamp (auto-added)
|
|
441
|
+
- `agent` - Agent name
|
|
442
|
+
|
|
443
|
+
### Event-Specific Root Fields
|
|
444
|
+
|
|
445
|
+
| Event | Root Fields | Nested Fields |
|
|
446
|
+
|-------|-------------|---------------|
|
|
447
|
+
| `swarm_start` | swarm_name, lead_agent, prompt | None |
|
|
448
|
+
| `swarm_stop` | swarm_name, lead_agent, last_agent, content, success, duration, total_cost, total_tokens, agents_involved | None |
|
|
449
|
+
| `agent_start` | swarm_name, model, provider, directory, system_prompt, tools, delegates_to | plugin_storages.* |
|
|
450
|
+
| `agent_stop` | model, content, tool_calls, finish_reason, tool_executions | usage.*, metadata.* |
|
|
451
|
+
| `agent_step` | model, content, tool_calls, finish_reason, tool_executions | usage.*, tool_calls[].*, metadata.* |
|
|
452
|
+
| `user_prompt` | model, provider, message_count, tools, delegates_to | metadata.* (includes prompt) |
|
|
453
|
+
| `tool_call` | tool_call_id, tool | arguments.*, metadata.* |
|
|
454
|
+
| `tool_result` | tool_call_id, tool, result | metadata.* |
|
|
455
|
+
|
|
456
|
+
### Important Notes
|
|
457
|
+
|
|
458
|
+
1. **Usage Information**: Always nested in `usage` hash within `agent_step` and `agent_stop` events
|
|
459
|
+
2. **Tool Calls**: Nested as array of objects in `tool_calls` field within `agent_step` events
|
|
460
|
+
3. **Prompt Location**: For `user_prompt` events, the prompt is in `metadata.prompt`, NOT at root level
|
|
461
|
+
4. **Metadata Deduplication**: `agent_step` and `agent_stop` events have minimal metadata because most fields are promoted to root level (see `swarm.rb:723` and `swarm.rb:744`)
|
|
462
|
+
|
|
463
|
+
---
|
|
464
|
+
|
|
465
|
+
## Code References
|
|
466
|
+
|
|
467
|
+
- **LogStream**: `lib/swarm_sdk/log_stream.rb` - Core emission mechanism
|
|
468
|
+
- **Event Emissions**: `lib/swarm_sdk/swarm.rb:664-809` - Default logging callbacks
|
|
469
|
+
- **Agent Events**: `lib/swarm_sdk/agent/chat/context_tracker.rb` - Agent-level event tracking
|
|
470
|
+
- **Hook Integration**: `lib/swarm_sdk/agent/chat/hook_integration.rb` - User prompt event preparation
|
|
471
|
+
- **Logging Helpers**: `lib/swarm_sdk/agent/chat/logging_helpers.rb` - Tool call/result formatting
|