claude_swarm 1.0.5 → 1.0.7
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/.ruby-version +1 -1
- data/CHANGELOG.md +23 -0
- data/README.md +336 -1037
- data/docs/V1_TO_V2_MIGRATION_GUIDE.md +1120 -0
- data/docs/v1/README.md +1195 -0
- data/docs/v2/CHANGELOG.swarm_cli.md +32 -0
- data/docs/v2/CHANGELOG.swarm_memory.md +20 -0
- data/docs/v2/CHANGELOG.swarm_sdk.md +333 -9
- data/docs/v2/README.md +88 -28
- data/docs/v2/guides/complete-tutorial.md +135 -39
- data/docs/v2/guides/composable-swarms.md +1178 -0
- data/docs/v2/guides/getting-started.md +48 -7
- data/docs/v2/guides/memory-defrag-guide.md +811 -0
- data/docs/v2/guides/rails-integration.md +6 -6
- data/docs/v2/guides/snapshots.md +1498 -0
- data/docs/v2/reference/architecture-flow.md +409 -0
- data/docs/v2/reference/event_payload_structures.md +708 -0
- data/docs/v2/reference/execution-flow.md +600 -0
- data/docs/v2/reference/ruby-dsl.md +368 -22
- data/docs/v2/reference/swarm_memory_technical_details.md +2 -2
- data/docs/v2/reference/yaml.md +314 -63
- data/examples/snapshot_demo.rb +119 -0
- data/examples/v2/dsl/01_basic.rb +0 -2
- data/examples/v2/dsl/02_core_parameters.rb +0 -2
- data/examples/v2/dsl/03_capabilities.rb +0 -2
- data/examples/v2/dsl/04_llm_parameters.rb +0 -2
- data/examples/v2/dsl/05_advanced_flags.rb +0 -3
- data/examples/v2/dsl/06_permissions.rb +0 -4
- data/examples/v2/dsl/07_mcp_server.rb +0 -2
- data/examples/v2/dsl/08_swarm_hooks.rb +0 -2
- data/examples/v2/dsl/09_agent_hooks.rb +0 -2
- data/examples/v2/dsl/10_all_agents_hooks.rb +0 -3
- data/examples/v2/dsl/11_delegation.rb +0 -2
- data/examples/v2/dsl/12_complete_integration.rb +2 -6
- data/examples/v2/node_context_demo.rb +1 -1
- data/examples/v2/node_workflow.rb +2 -4
- data/examples/v2/plan_and_execute.rb +157 -0
- data/examples/v2/swarm_with_hooks.yml +1 -1
- data/lib/claude_swarm/configuration.rb +28 -4
- 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/formatters/human_formatter.rb +103 -0
- data/lib/swarm_cli/interactive_repl.rb +9 -3
- data/lib/swarm_cli/version.rb +1 -1
- data/lib/swarm_memory/adapters/base.rb +4 -4
- data/lib/swarm_memory/core/storage_read_tracker.rb +51 -14
- data/lib/swarm_memory/integration/cli_registration.rb +3 -2
- data/lib/swarm_memory/integration/sdk_plugin.rb +11 -5
- data/lib/swarm_memory/tools/memory_edit.rb +2 -2
- data/lib/swarm_memory/tools/memory_multi_edit.rb +2 -2
- data/lib/swarm_memory/tools/memory_read.rb +3 -3
- data/lib/swarm_memory/version.rb +1 -1
- data/lib/swarm_memory.rb +5 -0
- data/lib/swarm_sdk/agent/builder.rb +33 -0
- data/lib/swarm_sdk/agent/chat/context_tracker.rb +33 -0
- data/lib/swarm_sdk/agent/chat/hook_integration.rb +49 -3
- data/lib/swarm_sdk/agent/chat/system_reminder_injector.rb +11 -27
- data/lib/swarm_sdk/agent/chat.rb +200 -51
- data/lib/swarm_sdk/agent/context.rb +6 -2
- data/lib/swarm_sdk/agent/context_manager.rb +6 -0
- data/lib/swarm_sdk/agent/definition.rb +15 -22
- data/lib/swarm_sdk/agent/llm_instrumentation_middleware.rb +180 -0
- data/lib/swarm_sdk/configuration.rb +420 -103
- data/lib/swarm_sdk/events_to_messages.rb +181 -0
- data/lib/swarm_sdk/log_collector.rb +31 -5
- data/lib/swarm_sdk/log_stream.rb +37 -8
- data/lib/swarm_sdk/model_aliases.json +4 -1
- data/lib/swarm_sdk/node/agent_config.rb +33 -8
- data/lib/swarm_sdk/node/builder.rb +39 -18
- data/lib/swarm_sdk/node_orchestrator.rb +293 -26
- data/lib/swarm_sdk/proc_helpers.rb +53 -0
- data/lib/swarm_sdk/prompts/base_system_prompt.md.erb +0 -126
- data/lib/swarm_sdk/providers/openai_with_responses.rb +22 -15
- data/lib/swarm_sdk/restore_result.rb +65 -0
- data/lib/swarm_sdk/snapshot.rb +156 -0
- data/lib/swarm_sdk/snapshot_from_events.rb +386 -0
- data/lib/swarm_sdk/state_restorer.rb +491 -0
- data/lib/swarm_sdk/state_snapshot.rb +369 -0
- data/lib/swarm_sdk/swarm/agent_initializer.rb +360 -55
- data/lib/swarm_sdk/swarm/all_agents_builder.rb +28 -1
- data/lib/swarm_sdk/swarm/builder.rb +208 -12
- data/lib/swarm_sdk/swarm/swarm_registry_builder.rb +67 -0
- data/lib/swarm_sdk/swarm/tool_configurator.rb +46 -11
- data/lib/swarm_sdk/swarm.rb +368 -90
- data/lib/swarm_sdk/swarm_loader.rb +145 -0
- data/lib/swarm_sdk/swarm_registry.rb +136 -0
- data/lib/swarm_sdk/tools/delegate.rb +92 -7
- data/lib/swarm_sdk/tools/read.rb +17 -5
- 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/read_tracker.rb +47 -12
- data/lib/swarm_sdk/tools/stores/scratchpad_storage.rb +45 -0
- 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/utils.rb +18 -0
- data/lib/swarm_sdk/validation_result.rb +33 -0
- data/lib/swarm_sdk/version.rb +1 -1
- data/lib/swarm_sdk.rb +362 -21
- data/swarm_cli.gemspec +1 -1
- data/swarm_memory.gemspec +2 -2
- data/swarm_sdk.gemspec +2 -2
- metadata +26 -182
- data/examples/learning-assistant/assistant.md +0 -7
- data/examples/learning-assistant/example-memories/concept-example.md +0 -90
- data/examples/learning-assistant/example-memories/experience-example.md +0 -66
- data/examples/learning-assistant/example-memories/fact-example.md +0 -76
- data/examples/learning-assistant/example-memories/memory-index.md +0 -78
- data/examples/learning-assistant/example-memories/skill-example.md +0 -168
- data/examples/learning-assistant/learning_assistant.rb +0 -34
- data/examples/learning-assistant/learning_assistant.yml +0 -20
- data/llm.v2.txt +0 -13407
- 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
- /data/{llms.txt → llms.claude-swarm.txt} +0 -0
|
@@ -0,0 +1,708 @@
|
|
|
1
|
+
# SwarmSDK Event Payload Structures
|
|
2
|
+
|
|
3
|
+
This document describes the exact structure of all SwarmSDK event payloads emitted via `LogStream.emit()`.
|
|
4
|
+
|
|
5
|
+
## Common Fields
|
|
6
|
+
|
|
7
|
+
All events automatically include these fields:
|
|
8
|
+
|
|
9
|
+
- `timestamp` (String): ISO8601 format timestamp, added by `LogStream.emit()`
|
|
10
|
+
- `swarm_id` (String): Unique identifier for the swarm that emitted this event
|
|
11
|
+
- `parent_swarm_id` (String | nil): Parent swarm ID (null for root swarms)
|
|
12
|
+
|
|
13
|
+
**Hierarchical Tracking:**
|
|
14
|
+
For composable swarms, events include hierarchical swarm IDs:
|
|
15
|
+
- Root swarm: `swarm_id: "main"`, `parent_swarm_id: null`
|
|
16
|
+
- Child swarm: `swarm_id: "main/code_review"`, `parent_swarm_id: "main"`
|
|
17
|
+
- Grandchild: `swarm_id: "main/code_review/security"`, `parent_swarm_id: "main/code_review"`
|
|
18
|
+
|
|
19
|
+
**Agent Identification:**
|
|
20
|
+
Most events include an `agent` field (Symbol) that identifies which agent emitted the event:
|
|
21
|
+
- **Primary agents**: Simple name like `:backend`, `:frontend`
|
|
22
|
+
- **Delegation instances**: Compound name like `:"backend@lead"`, `:"backend@frontend"`
|
|
23
|
+
- Format: `:"target@delegator"` where target is the delegated-to agent and delegator is the delegating agent
|
|
24
|
+
- Created when multiple agents delegate to the same target (unless `shared_across_delegations: true`)
|
|
25
|
+
- Each instance has isolated conversation history and tool state
|
|
26
|
+
- See the `agent_start` event documentation for more details
|
|
27
|
+
|
|
28
|
+
## Event Types
|
|
29
|
+
|
|
30
|
+
### 1. swarm_start
|
|
31
|
+
|
|
32
|
+
Emitted when `Swarm.execute()` is called, before any agent execution begins.
|
|
33
|
+
|
|
34
|
+
**Location**: `lib/swarm_sdk/swarm.rb:670-677`
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
{
|
|
38
|
+
type: "swarm_start",
|
|
39
|
+
timestamp: "2025-01-15T10:30:45Z", # Auto-added by LogStream
|
|
40
|
+
agent: :lead_agent_name, # Lead agent name (for consistency)
|
|
41
|
+
swarm_id: "main", # Swarm ID
|
|
42
|
+
parent_swarm_id: nil, # Parent swarm ID (nil for root)
|
|
43
|
+
swarm_name: "Development Team", # Swarm name
|
|
44
|
+
lead_agent: :lead_agent_name, # Lead agent name
|
|
45
|
+
prompt: "Build authentication system" # User's task prompt
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Field Locations**:
|
|
50
|
+
- Root level: `type`, `timestamp`, `agent`, `swarm_id`, `parent_swarm_id`, `swarm_name`, `lead_agent`, `prompt`
|
|
51
|
+
- No nested metadata
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### 2. swarm_stop
|
|
56
|
+
|
|
57
|
+
Emitted when swarm execution completes (success or error).
|
|
58
|
+
|
|
59
|
+
**Location**: `lib/swarm_sdk/swarm.rb:685-696`
|
|
60
|
+
|
|
61
|
+
```ruby
|
|
62
|
+
{
|
|
63
|
+
type: "swarm_stop",
|
|
64
|
+
timestamp: "2025-01-15T10:35:22Z",
|
|
65
|
+
swarm_id: "main", # Swarm ID
|
|
66
|
+
parent_swarm_id: nil, # Parent swarm ID (nil for root)
|
|
67
|
+
swarm_name: "Development Team",
|
|
68
|
+
lead_agent: :lead_agent_name,
|
|
69
|
+
last_agent: "backend", # Agent that produced final response
|
|
70
|
+
content: "Authentication system complete", # Final response content (can be nil)
|
|
71
|
+
success: true, # Boolean: true if no error
|
|
72
|
+
duration: 277.5, # Seconds (Float)
|
|
73
|
+
total_cost: 0.00234, # USD (Float)
|
|
74
|
+
total_tokens: 12450, # Integer
|
|
75
|
+
agents_involved: [:lead, :backend, :frontend] # Array of agent names
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Field Locations**:
|
|
80
|
+
- Root level: All fields including `swarm_id` and `parent_swarm_id`
|
|
81
|
+
- No nested metadata for this event
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
### 3. agent_start
|
|
86
|
+
|
|
87
|
+
Emitted once per agent when agents are initialized (lazy initialization).
|
|
88
|
+
|
|
89
|
+
**Location**: `lib/swarm_sdk/swarm.rb:567-578`
|
|
90
|
+
|
|
91
|
+
```ruby
|
|
92
|
+
{
|
|
93
|
+
type: "agent_start",
|
|
94
|
+
timestamp: "2025-01-15T10:30:46Z",
|
|
95
|
+
agent: :backend, # Agent name (or delegation instance name)
|
|
96
|
+
swarm_id: "main", # Swarm ID
|
|
97
|
+
parent_swarm_id: nil, # Parent swarm ID (nil for root)
|
|
98
|
+
swarm_name: "Development Team",
|
|
99
|
+
model: "gpt-5", # Model ID
|
|
100
|
+
provider: "openai", # Provider name
|
|
101
|
+
directory: "./backend", # Working directory
|
|
102
|
+
system_prompt: "You are a backend dev...", # Full system prompt
|
|
103
|
+
tools: [:Read, :Edit, :Bash, :DelegateTaskToFrontend], # Array of tool names
|
|
104
|
+
delegates_to: [:frontend], # Array of delegate agent names
|
|
105
|
+
plugin_storages: { # Plugin storage info (optional)
|
|
106
|
+
memory: {
|
|
107
|
+
enabled: true,
|
|
108
|
+
config: { directory: ".swarm/backend-memory" }
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
is_delegation_instance: false, # True if this is a delegation instance
|
|
112
|
+
base_agent: nil # Base agent name (if delegation instance)
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Field Locations**:
|
|
117
|
+
- Root level: All fields including `swarm_id` and `parent_swarm_id`
|
|
118
|
+
- Nested in `plugin_storages`: Per-plugin configuration
|
|
119
|
+
|
|
120
|
+
**Delegation Instances:**
|
|
121
|
+
|
|
122
|
+
When multiple agents delegate to the same target agent, SwarmSDK creates isolated instances by default (controlled by `shared_across_delegations` config). These instances have unique names and separate state:
|
|
123
|
+
|
|
124
|
+
```ruby
|
|
125
|
+
# Primary agent
|
|
126
|
+
{
|
|
127
|
+
type: "agent_start",
|
|
128
|
+
agent: :backend,
|
|
129
|
+
is_delegation_instance: false,
|
|
130
|
+
base_agent: nil,
|
|
131
|
+
...
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
# Delegation instance (when lead delegates to backend)
|
|
135
|
+
{
|
|
136
|
+
type: "agent_start",
|
|
137
|
+
agent: :"backend@lead", # Format: target@delegator
|
|
138
|
+
is_delegation_instance: true,
|
|
139
|
+
base_agent: :backend, # Original agent definition
|
|
140
|
+
...
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
# Another delegation instance (when frontend delegates to backend)
|
|
144
|
+
{
|
|
145
|
+
type: "agent_start",
|
|
146
|
+
agent: :"backend@frontend", # Separate isolated instance
|
|
147
|
+
is_delegation_instance: true,
|
|
148
|
+
base_agent: :backend,
|
|
149
|
+
...
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Key Points:**
|
|
154
|
+
- Each delegation instance has **isolated conversation history** and **separate tool state**
|
|
155
|
+
- All instances use the **same configuration** (model, tools, prompts) from the base agent
|
|
156
|
+
- The `agent` field shows the full instance name for proper tracking
|
|
157
|
+
- Set `shared_across_delegations: true` on the base agent to share one instance across all delegators
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
### 4. agent_stop
|
|
162
|
+
|
|
163
|
+
Emitted when an agent completes with a final response (no more tool calls).
|
|
164
|
+
|
|
165
|
+
**Location**: `lib/swarm_sdk/swarm.rb:746-756`
|
|
166
|
+
|
|
167
|
+
```ruby
|
|
168
|
+
{
|
|
169
|
+
type: "agent_stop",
|
|
170
|
+
timestamp: "2025-01-15T10:31:20Z",
|
|
171
|
+
agent: "backend",
|
|
172
|
+
swarm_id: "main", # Swarm ID
|
|
173
|
+
parent_swarm_id: nil, # Parent swarm ID (nil for root)
|
|
174
|
+
model: "gpt-5",
|
|
175
|
+
content: "I've implemented the auth system", # Final response text
|
|
176
|
+
tool_calls: nil, # Always nil for agent_stop
|
|
177
|
+
finish_reason: "stop", # "stop", "finish_agent", "finish_swarm"
|
|
178
|
+
usage: { # Usage statistics
|
|
179
|
+
input_tokens: 2450,
|
|
180
|
+
output_tokens: 856,
|
|
181
|
+
total_tokens: 3306,
|
|
182
|
+
input_cost: 0.001225,
|
|
183
|
+
output_cost: 0.000428,
|
|
184
|
+
total_cost: 0.001653,
|
|
185
|
+
cumulative_input_tokens: 8920, # Total for entire conversation
|
|
186
|
+
cumulative_output_tokens: 3530,
|
|
187
|
+
cumulative_total_tokens: 12450,
|
|
188
|
+
context_limit: 200000,
|
|
189
|
+
tokens_used_percentage: "6.23%",
|
|
190
|
+
tokens_remaining: 187550
|
|
191
|
+
},
|
|
192
|
+
tool_executions: nil, # Array of tool execution results (if any)
|
|
193
|
+
metadata: { # Additional context (minimal)
|
|
194
|
+
# Fields promoted to root level are excluded here
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Field Locations**:
|
|
200
|
+
- Root level: `type`, `timestamp`, `agent`, `swarm_id`, `parent_swarm_id`, `model`, `content`, `tool_calls`, `finish_reason`, `tool_executions`, `metadata`
|
|
201
|
+
- Nested in `usage`: All token counts, costs, and context tracking
|
|
202
|
+
- Nested in `metadata`: Minimal (most fields promoted to root)
|
|
203
|
+
|
|
204
|
+
**Note**: The `metadata` field in `agent_stop` has most fields extracted to root level to avoid duplication (see `swarm.rb:743`).
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
### 5. agent_step
|
|
209
|
+
|
|
210
|
+
Emitted when an agent makes an intermediate response with tool calls (agent hasn't finished yet).
|
|
211
|
+
|
|
212
|
+
**Location**: `lib/swarm_sdk/swarm.rb:725-735`
|
|
213
|
+
|
|
214
|
+
```ruby
|
|
215
|
+
{
|
|
216
|
+
type: "agent_step",
|
|
217
|
+
timestamp: "2025-01-15T10:31:15Z",
|
|
218
|
+
agent: "backend",
|
|
219
|
+
model: "gpt-5",
|
|
220
|
+
content: "I'll read the config files", # Agent's reasoning/message
|
|
221
|
+
tool_calls: [ # Array of tool calls
|
|
222
|
+
{
|
|
223
|
+
id: "call_abc123",
|
|
224
|
+
name: "Read",
|
|
225
|
+
arguments: { file_path: "config/auth.rb" }
|
|
226
|
+
}
|
|
227
|
+
],
|
|
228
|
+
finish_reason: "tool_calls", # Always "tool_calls" for agent_step
|
|
229
|
+
usage: { # Same structure as agent_stop
|
|
230
|
+
input_tokens: 1850,
|
|
231
|
+
output_tokens: 156,
|
|
232
|
+
total_tokens: 2006,
|
|
233
|
+
input_cost: 0.000925,
|
|
234
|
+
output_cost: 0.000078,
|
|
235
|
+
total_cost: 0.001003,
|
|
236
|
+
cumulative_input_tokens: 6470,
|
|
237
|
+
cumulative_output_tokens: 2674,
|
|
238
|
+
cumulative_total_tokens: 9144,
|
|
239
|
+
context_limit: 200000,
|
|
240
|
+
tokens_used_percentage: "4.57%",
|
|
241
|
+
tokens_remaining: 190856
|
|
242
|
+
},
|
|
243
|
+
tool_executions: [], # Usually empty for steps (filled on completion)
|
|
244
|
+
metadata: {
|
|
245
|
+
# Fields promoted to root level are excluded here
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**Field Locations**:
|
|
251
|
+
- Root level: `type`, `timestamp`, `agent`, `model`, `content`, `tool_calls`, `finish_reason`, `usage`, `tool_executions`, `metadata`
|
|
252
|
+
- Nested in `tool_calls`: Array of `{ id, name, arguments }` objects
|
|
253
|
+
- Nested in `usage`: All token and cost information
|
|
254
|
+
- Nested in `metadata`: Minimal (most fields promoted to root)
|
|
255
|
+
|
|
256
|
+
**Note**: Similar to `agent_stop`, but `finish_reason` is always `"tool_calls"` and `tool_calls` array is populated.
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
### 6. user_prompt
|
|
261
|
+
|
|
262
|
+
Emitted when a user message is about to be sent to the LLM.
|
|
263
|
+
|
|
264
|
+
**Location**: `lib/swarm_sdk/swarm.rb:705-714`
|
|
265
|
+
|
|
266
|
+
```ruby
|
|
267
|
+
{
|
|
268
|
+
type: "user_prompt",
|
|
269
|
+
timestamp: "2025-01-15T10:31:10Z",
|
|
270
|
+
agent: "backend",
|
|
271
|
+
model: "gpt-5",
|
|
272
|
+
provider: "openai",
|
|
273
|
+
message_count: 5, # Number of messages in conversation so far
|
|
274
|
+
tools: [:Read, :Edit, :Bash], # Available tools (excluding delegation tools)
|
|
275
|
+
delegates_to: ["frontend"], # Agents this agent can delegate to
|
|
276
|
+
source: "user", # Source of prompt: "user" or "delegation"
|
|
277
|
+
metadata: { # Full context available here
|
|
278
|
+
prompt: "Build authentication",
|
|
279
|
+
message_count: 5,
|
|
280
|
+
model: "gpt-5",
|
|
281
|
+
provider: "openai",
|
|
282
|
+
tools: [:Read, :Edit, :Bash],
|
|
283
|
+
delegates_to: ["frontend"],
|
|
284
|
+
source: "user",
|
|
285
|
+
timestamp: "2025-01-15T10:31:10Z"
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**Field Locations**:
|
|
291
|
+
- Root level: `type`, `timestamp`, `agent`, `model`, `provider`, `message_count`, `tools`, `delegates_to`, `source`, `metadata`
|
|
292
|
+
- Nested in `metadata`: Complete copy of all context fields (including prompt and source)
|
|
293
|
+
|
|
294
|
+
**Source Field**:
|
|
295
|
+
- `"user"` - Direct user interaction (default)
|
|
296
|
+
- `"delegation"` - Prompt originated from delegation tool (one agent delegating to another)
|
|
297
|
+
|
|
298
|
+
**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.
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
### 7. tool_call
|
|
303
|
+
|
|
304
|
+
Emitted before a tool is executed (pre_tool_use hook).
|
|
305
|
+
|
|
306
|
+
**Location**: `lib/swarm_sdk/swarm.rb:766-773`
|
|
307
|
+
|
|
308
|
+
```ruby
|
|
309
|
+
{
|
|
310
|
+
type: "tool_call",
|
|
311
|
+
timestamp: "2025-01-15T10:31:16Z",
|
|
312
|
+
agent: "backend",
|
|
313
|
+
tool_call_id: "call_abc123", # Unique call ID
|
|
314
|
+
tool: "Read", # Tool name
|
|
315
|
+
arguments: { # Tool parameters
|
|
316
|
+
file_path: "config/auth.rb"
|
|
317
|
+
},
|
|
318
|
+
metadata: {} # Additional context (usually empty)
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
**Field Locations**:
|
|
323
|
+
- Root level: `type`, `timestamp`, `agent`, `tool_call_id`, `tool`, `arguments`, `metadata`
|
|
324
|
+
- Nested in `arguments`: Tool-specific parameters
|
|
325
|
+
- Nested in `metadata`: Additional context (typically minimal)
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
### 8. tool_result
|
|
330
|
+
|
|
331
|
+
Emitted after a tool completes execution (post_tool_use hook).
|
|
332
|
+
|
|
333
|
+
**Location**: `lib/swarm_sdk/swarm.rb:783-790`
|
|
334
|
+
|
|
335
|
+
```ruby
|
|
336
|
+
{
|
|
337
|
+
type: "tool_result",
|
|
338
|
+
timestamp: "2025-01-15T10:31:17Z",
|
|
339
|
+
agent: "backend",
|
|
340
|
+
tool_call_id: "call_abc123", # Matches the tool_call ID
|
|
341
|
+
tool: "Read", # Tool name
|
|
342
|
+
result: "# Authentication config\n...", # Tool output (can be String, Hash, Array)
|
|
343
|
+
metadata: {} # Additional context (usually empty)
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
**Field Locations**:
|
|
348
|
+
- Root level: `type`, `timestamp`, `agent`, `tool_call_id`, `tool`, `result`, `metadata`
|
|
349
|
+
- `result` can be:
|
|
350
|
+
- String: Direct text output
|
|
351
|
+
- Hash/Array: Structured data
|
|
352
|
+
- See `LoggingHelpers.serialize_result()` for how different types are handled
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Additional Event Types
|
|
357
|
+
|
|
358
|
+
### 9. model_lookup_warning
|
|
359
|
+
|
|
360
|
+
Emitted when a model isn't found in the registry during initialization.
|
|
361
|
+
|
|
362
|
+
**Location**: `lib/swarm_sdk/swarm.rb:445-452`
|
|
363
|
+
|
|
364
|
+
```ruby
|
|
365
|
+
{
|
|
366
|
+
type: "model_lookup_warning",
|
|
367
|
+
timestamp: "2025-01-15T10:30:46Z",
|
|
368
|
+
agent: :backend,
|
|
369
|
+
model: "gpt-5-turbo", # Invalid model name
|
|
370
|
+
error_message: "Model 'gpt-5-turbo' not...", # Error description
|
|
371
|
+
suggestions: [ # Similar models found
|
|
372
|
+
{
|
|
373
|
+
id: "gpt-5",
|
|
374
|
+
name: "GPT-5",
|
|
375
|
+
context_window: 200000
|
|
376
|
+
}
|
|
377
|
+
]
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
### 10. context_limit_warning
|
|
384
|
+
|
|
385
|
+
Emitted when context usage crosses threshold percentages (60%, 80%, 90%, 95%).
|
|
386
|
+
|
|
387
|
+
**Location**: `lib/swarm_sdk/swarm.rb:798-808`
|
|
388
|
+
|
|
389
|
+
```ruby
|
|
390
|
+
{
|
|
391
|
+
type: "context_limit_warning",
|
|
392
|
+
timestamp: "2025-01-15T10:32:45Z",
|
|
393
|
+
agent: "backend",
|
|
394
|
+
model: "gpt-5",
|
|
395
|
+
threshold: "80%", # Threshold crossed
|
|
396
|
+
current_usage: "82.5%", # Current usage
|
|
397
|
+
tokens_used: 165000,
|
|
398
|
+
tokens_remaining: 35000,
|
|
399
|
+
context_limit: 200000,
|
|
400
|
+
metadata: {} # Agent context metadata
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
### 11. agent_delegation
|
|
407
|
+
|
|
408
|
+
Emitted when an agent delegates work to another agent or swarm.
|
|
409
|
+
|
|
410
|
+
**Location**: `lib/swarm_sdk/agent/chat/context_tracker.rb:186-193`
|
|
411
|
+
|
|
412
|
+
```ruby
|
|
413
|
+
{
|
|
414
|
+
type: "agent_delegation",
|
|
415
|
+
timestamp: "2025-01-15T10:31:30Z",
|
|
416
|
+
agent: "backend",
|
|
417
|
+
swarm_id: "main", # Swarm ID
|
|
418
|
+
parent_swarm_id: nil, # Parent swarm ID (nil for root)
|
|
419
|
+
tool_call_id: "call_xyz789",
|
|
420
|
+
delegate_to: "frontend", # Target agent or swarm name
|
|
421
|
+
arguments: { # Delegation parameters
|
|
422
|
+
prompt: "Build the login UI"
|
|
423
|
+
},
|
|
424
|
+
metadata: {} # Agent context metadata
|
|
425
|
+
}
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
**Note**: `delegate_to` can be either a local agent name or a registered swarm name when using composable swarms.
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
### 12. delegation_result
|
|
433
|
+
|
|
434
|
+
Emitted when a delegated task completes and returns to the delegating agent.
|
|
435
|
+
|
|
436
|
+
**Location**: `lib/swarm_sdk/agent/chat/context_tracker.rb:163-170`
|
|
437
|
+
|
|
438
|
+
```ruby
|
|
439
|
+
{
|
|
440
|
+
type: "delegation_result",
|
|
441
|
+
timestamp: "2025-01-15T10:32:15Z",
|
|
442
|
+
agent: "backend", # Agent that delegated
|
|
443
|
+
swarm_id: "main", # Swarm ID
|
|
444
|
+
parent_swarm_id: nil, # Parent swarm ID (nil for root)
|
|
445
|
+
delegate_from: "frontend", # Agent or swarm that was delegated to
|
|
446
|
+
tool_call_id: "call_xyz789", # Matches delegation tool_call_id
|
|
447
|
+
result: "Login UI implemented", # Result from delegate
|
|
448
|
+
metadata: {} # Agent context metadata
|
|
449
|
+
}
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
### 12a. delegation_circular_dependency
|
|
455
|
+
|
|
456
|
+
Emitted when circular delegation is detected (prevents infinite loops).
|
|
457
|
+
|
|
458
|
+
**Location**: `lib/swarm_sdk/tools/delegate.rb:192-200`
|
|
459
|
+
|
|
460
|
+
```ruby
|
|
461
|
+
{
|
|
462
|
+
type: "delegation_circular_dependency",
|
|
463
|
+
timestamp: "2025-01-15T10:31:45Z",
|
|
464
|
+
agent: "agent_b", # Agent attempting delegation
|
|
465
|
+
swarm_id: "main", # Swarm ID
|
|
466
|
+
parent_swarm_id: nil, # Parent swarm ID (nil for root)
|
|
467
|
+
target: "agent_a", # Target that would create cycle
|
|
468
|
+
call_stack: ["agent_a", "agent_b"] # Current delegation chain
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
**Description**: Emitted when runtime circular dependency detection prevents an infinite delegation loop. The delegation is blocked and an error message is returned to the LLM.
|
|
473
|
+
|
|
474
|
+
**Example Scenarios:**
|
|
475
|
+
- Agent A → Agent B → Agent A (circular within swarm)
|
|
476
|
+
- Swarm S1 → Swarm S2 → Swarm S1 (circular across swarms)
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
480
|
+
### 13. context_compression
|
|
481
|
+
|
|
482
|
+
Emitted when automatic context compression is triggered at 60% threshold.
|
|
483
|
+
|
|
484
|
+
**Location**: `lib/swarm_sdk/agent/chat/context_tracker.rb:301-310`
|
|
485
|
+
|
|
486
|
+
```ruby
|
|
487
|
+
{
|
|
488
|
+
type: "context_compression",
|
|
489
|
+
timestamp: "2025-01-15T10:33:00Z",
|
|
490
|
+
agent: "backend",
|
|
491
|
+
total_messages: 45, # Total messages after compression
|
|
492
|
+
messages_compressed: 12, # Number of messages compressed
|
|
493
|
+
tokens_before: 125000, # Token count before compression
|
|
494
|
+
current_usage: "62.5%", # Usage after compression
|
|
495
|
+
compression_strategy: "progressive_tool_result_compression",
|
|
496
|
+
keep_recent: 10 # Number of recent messages kept uncompressed
|
|
497
|
+
}
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
### 14. llm_retry_attempt
|
|
503
|
+
|
|
504
|
+
Emitted when an LLM API call fails and is being retried.
|
|
505
|
+
|
|
506
|
+
**Location**: `lib/swarm_sdk/agent/chat.rb:813-823`
|
|
507
|
+
|
|
508
|
+
```ruby
|
|
509
|
+
{
|
|
510
|
+
type: "llm_retry_attempt",
|
|
511
|
+
timestamp: "2025-01-15T10:31:18Z",
|
|
512
|
+
agent: "backend",
|
|
513
|
+
model: "gpt-5",
|
|
514
|
+
attempt: 1, # Current attempt number
|
|
515
|
+
max_retries: 10, # Maximum retries
|
|
516
|
+
error_class: "Faraday::ConnectionFailed", # Error class name
|
|
517
|
+
error_message: "Connection refused", # Error message
|
|
518
|
+
retry_delay: 10 # Seconds before next retry
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
### 15. llm_retry_exhausted
|
|
525
|
+
|
|
526
|
+
Emitted when all LLM API retry attempts are exhausted.
|
|
527
|
+
|
|
528
|
+
**Location**: `lib/swarm_sdk/agent/chat.rb:802-809`
|
|
529
|
+
|
|
530
|
+
```ruby
|
|
531
|
+
{
|
|
532
|
+
type: "llm_retry_exhausted",
|
|
533
|
+
timestamp: "2025-01-15T10:33:30Z",
|
|
534
|
+
agent: "backend",
|
|
535
|
+
model: "gpt-5",
|
|
536
|
+
attempts: 10, # Total attempts made
|
|
537
|
+
error_class: "Faraday::ConnectionFailed",
|
|
538
|
+
error_message: "Connection refused"
|
|
539
|
+
}
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
---
|
|
543
|
+
|
|
544
|
+
### 16. llm_api_request
|
|
545
|
+
|
|
546
|
+
Emitted before sending HTTP request to LLM API provider (only when logging is enabled).
|
|
547
|
+
|
|
548
|
+
**Location**: `lib/swarm_sdk/agent/llm_instrumentation_middleware.rb:57-68`
|
|
549
|
+
|
|
550
|
+
```ruby
|
|
551
|
+
{
|
|
552
|
+
type: "llm_api_request",
|
|
553
|
+
timestamp: "2025-01-15T10:31:15Z",
|
|
554
|
+
agent: "backend",
|
|
555
|
+
swarm_id: "main", # Swarm ID
|
|
556
|
+
parent_swarm_id: nil, # Parent swarm ID (nil for root)
|
|
557
|
+
provider: "openai", # Provider name (e.g., "anthropic", "openai")
|
|
558
|
+
body: { # Complete request payload
|
|
559
|
+
model: "gpt-5",
|
|
560
|
+
messages: [
|
|
561
|
+
{ role: "system", content: "You are..." },
|
|
562
|
+
{ role: "user", content: "Build authentication" }
|
|
563
|
+
],
|
|
564
|
+
temperature: 0.7,
|
|
565
|
+
max_tokens: 4096,
|
|
566
|
+
tools: [ # Tool definitions (if any)
|
|
567
|
+
{
|
|
568
|
+
name: "Read",
|
|
569
|
+
description: "Read a file",
|
|
570
|
+
input_schema: { ... }
|
|
571
|
+
}
|
|
572
|
+
]
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
**Field Locations**:
|
|
578
|
+
- Root level: `type`, `timestamp`, `agent`, `swarm_id`, `parent_swarm_id`, `provider`, `body`
|
|
579
|
+
- Nested in `body`: Complete LLM request payload (model, messages, parameters, tools)
|
|
580
|
+
|
|
581
|
+
**Notes**:
|
|
582
|
+
- Only emitted when logging is enabled (`swarm.execute` with block)
|
|
583
|
+
- Body structure varies by provider (OpenAI, Anthropic, etc.)
|
|
584
|
+
- HTTP-level details (method, URL, headers) are not included to reduce noise
|
|
585
|
+
- Captures the exact request sent to the LLM API
|
|
586
|
+
|
|
587
|
+
**Delegation Instance Example:**
|
|
588
|
+
|
|
589
|
+
When a delegation instance makes an LLM API call, the `agent` field shows the full instance name:
|
|
590
|
+
|
|
591
|
+
```ruby
|
|
592
|
+
{
|
|
593
|
+
type: "llm_api_request",
|
|
594
|
+
agent: :"backend@lead", # Delegation instance identifier
|
|
595
|
+
swarm_id: "main",
|
|
596
|
+
parent_swarm_id: nil,
|
|
597
|
+
provider: "openai",
|
|
598
|
+
body: { ... }
|
|
599
|
+
}
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
This allows you to track which specific delegation instance (and therefore which delegation path) triggered the API call.
|
|
603
|
+
|
|
604
|
+
---
|
|
605
|
+
|
|
606
|
+
### 17. llm_api_response
|
|
607
|
+
|
|
608
|
+
Emitted after receiving HTTP response from LLM API provider (only when logging is enabled).
|
|
609
|
+
|
|
610
|
+
**Location**: `lib/swarm_sdk/agent/llm_instrumentation_middleware.rb:77-101`
|
|
611
|
+
|
|
612
|
+
```ruby
|
|
613
|
+
{
|
|
614
|
+
type: "llm_api_response",
|
|
615
|
+
timestamp: "2025-01-15T10:31:17Z",
|
|
616
|
+
agent: "backend",
|
|
617
|
+
swarm_id: "main", # Swarm ID
|
|
618
|
+
parent_swarm_id: nil, # Parent swarm ID (nil for root)
|
|
619
|
+
provider: "openai", # Provider name
|
|
620
|
+
body: { # Complete response payload
|
|
621
|
+
id: "chatcmpl-123",
|
|
622
|
+
object: "chat.completion",
|
|
623
|
+
created: 1642234567,
|
|
624
|
+
model: "gpt-5",
|
|
625
|
+
choices: [
|
|
626
|
+
{
|
|
627
|
+
index: 0,
|
|
628
|
+
message: {
|
|
629
|
+
role: "assistant",
|
|
630
|
+
content: "I'll implement the authentication system...",
|
|
631
|
+
tool_calls: [...]
|
|
632
|
+
},
|
|
633
|
+
finish_reason: "tool_calls"
|
|
634
|
+
}
|
|
635
|
+
],
|
|
636
|
+
usage: {
|
|
637
|
+
prompt_tokens: 1850,
|
|
638
|
+
completion_tokens: 156,
|
|
639
|
+
total_tokens: 2006
|
|
640
|
+
}
|
|
641
|
+
},
|
|
642
|
+
duration_seconds: 2.145, # Request duration
|
|
643
|
+
usage: { # Extracted from body
|
|
644
|
+
input_tokens: 1850,
|
|
645
|
+
output_tokens: 156,
|
|
646
|
+
total_tokens: 2006
|
|
647
|
+
},
|
|
648
|
+
model: "gpt-5", # Extracted from body
|
|
649
|
+
finish_reason: "tool_calls" # Extracted from body
|
|
650
|
+
}
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
**Field Locations**:
|
|
654
|
+
- Root level: `type`, `timestamp`, `agent`, `swarm_id`, `parent_swarm_id`, `provider`, `body`, `duration_seconds`, `usage`, `model`, `finish_reason`
|
|
655
|
+
- Nested in `body`: Complete LLM response payload (varies by provider)
|
|
656
|
+
- Nested in `usage`: Token counts (extracted from body for convenience)
|
|
657
|
+
|
|
658
|
+
**Notes**:
|
|
659
|
+
- Only emitted when logging is enabled (`swarm.execute` with block)
|
|
660
|
+
- `usage`, `model`, and `finish_reason` are extracted from the body for convenience
|
|
661
|
+
- Body structure varies by provider (OpenAI, Anthropic, etc.)
|
|
662
|
+
- HTTP-level details (status, headers) are not included to reduce noise
|
|
663
|
+
- Captures the exact response received from the LLM API
|
|
664
|
+
- Duration includes full round-trip time (request + network + response)
|
|
665
|
+
|
|
666
|
+
---
|
|
667
|
+
|
|
668
|
+
## Summary: Field Location Guide
|
|
669
|
+
|
|
670
|
+
### Always at Root Level
|
|
671
|
+
- `type` - Event type identifier
|
|
672
|
+
- `timestamp` - ISO8601 timestamp (auto-added)
|
|
673
|
+
- `agent` - Agent name
|
|
674
|
+
|
|
675
|
+
### Event-Specific Root Fields
|
|
676
|
+
|
|
677
|
+
| Event | Root Fields | Nested Fields |
|
|
678
|
+
|-------|-------------|---------------|
|
|
679
|
+
| `swarm_start` | swarm_name, lead_agent, prompt | None |
|
|
680
|
+
| `swarm_stop` | swarm_name, lead_agent, last_agent, content, success, duration, total_cost, total_tokens, agents_involved | None |
|
|
681
|
+
| `agent_start` | swarm_name, model, provider, directory, system_prompt, tools, delegates_to | plugin_storages.* |
|
|
682
|
+
| `agent_stop` | model, content, tool_calls, finish_reason, tool_executions | usage.*, metadata.* |
|
|
683
|
+
| `agent_step` | model, content, tool_calls, finish_reason, tool_executions | usage.*, tool_calls[].*, metadata.* |
|
|
684
|
+
| `user_prompt` | model, provider, message_count, tools, delegates_to | metadata.* (includes prompt) |
|
|
685
|
+
| `tool_call` | tool_call_id, tool | arguments.*, metadata.* |
|
|
686
|
+
| `tool_result` | tool_call_id, tool, result | metadata.* |
|
|
687
|
+
| `llm_api_request` | provider | body.* |
|
|
688
|
+
| `llm_api_response` | provider, duration_seconds, usage, model, finish_reason | body.*, usage.* |
|
|
689
|
+
|
|
690
|
+
### Important Notes
|
|
691
|
+
|
|
692
|
+
1. **Usage Information**: Always nested in `usage` hash within `agent_step` and `agent_stop` events
|
|
693
|
+
2. **Tool Calls**: Nested as array of objects in `tool_calls` field within `agent_step` events
|
|
694
|
+
3. **Prompt Location**: For `user_prompt` events, the prompt is in `metadata.prompt`, NOT at root level
|
|
695
|
+
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`)
|
|
696
|
+
5. **LLM API Events**: `llm_api_request` and `llm_api_response` events are only emitted when logging is enabled and capture the raw LLM API communication for debugging and monitoring
|
|
697
|
+
6. **Delegation Instances**: The `agent` field can be either a simple agent name (`:backend`) or a delegation instance name (`:"backend@lead"`). Delegation instances are created automatically when multiple agents delegate to the same target (unless `shared_across_delegations: true`). Each instance has isolated state and appears as a distinct agent in all events, allowing you to track behavior and costs per delegation path.
|
|
698
|
+
|
|
699
|
+
---
|
|
700
|
+
|
|
701
|
+
## Code References
|
|
702
|
+
|
|
703
|
+
- **LogStream**: `lib/swarm_sdk/log_stream.rb` - Core emission mechanism
|
|
704
|
+
- **Event Emissions**: `lib/swarm_sdk/swarm.rb:664-809` - Default logging callbacks
|
|
705
|
+
- **Agent Events**: `lib/swarm_sdk/agent/chat/context_tracker.rb` - Agent-level event tracking
|
|
706
|
+
- **Hook Integration**: `lib/swarm_sdk/agent/chat/hook_integration.rb` - User prompt event preparation
|
|
707
|
+
- **Logging Helpers**: `lib/swarm_sdk/agent/chat/logging_helpers.rb` - Tool call/result formatting
|
|
708
|
+
- **LLM Instrumentation**: `lib/swarm_sdk/agent/llm_instrumentation_middleware.rb` - LLM API request/response capture
|