{"id":28965873,"url":"https://github.com/feiskyer/swarm-go","last_synced_at":"2025-06-24T07:10:22.892Z","repository":{"id":263098116,"uuid":"888475850","full_name":"feiskyer/swarm-go","owner":"feiskyer","description":"An ergonomic, lightweight multi-agent orchestration in Go","archived":false,"fork":false,"pushed_at":"2025-03-28T02:55:28.000Z","size":87,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T03:28:04.554Z","etag":null,"topics":["agent","agentic-framework","copilot","openai"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/feiskyer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-14T13:16:39.000Z","updated_at":"2025-03-28T02:54:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"40dc78cd-0efa-4f31-b6aa-b12daa2e068c","html_url":"https://github.com/feiskyer/swarm-go","commit_stats":null,"previous_names":["feiskyer/swarm-go"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/feiskyer/swarm-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feiskyer%2Fswarm-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feiskyer%2Fswarm-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feiskyer%2Fswarm-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feiskyer%2Fswarm-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/feiskyer","download_url":"https://codeload.github.com/feiskyer/swarm-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feiskyer%2Fswarm-go/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261624969,"owners_count":23186121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","agentic-framework","copilot","openai"],"created_at":"2025-06-24T07:10:21.880Z","updated_at":"2025-06-24T07:10:22.884Z","avatar_url":"https://github.com/feiskyer.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swarm\n\nAn **ergonomic** and **lightweight** multi-agent orchestration framework inspired by [OpenAI's Swarm](https://github.com/openai/swarm). Designed for simplicity and efficiency, this framework empowers developers to build scalable and flexible multi-agent systems in Go.\n\n**Features:**\n\n- 🚀 **Lightweight Orchestration**: Efficiently manage multi-agent systems with a minimalistic and performant design. Perfect for applications where simplicity and speed are critical.\n- 🛠️ **Native Function Calls**: Seamlessly integrate with your existing tools and services using native Go function calls. No complex wrappers or unnecessary abstractions—just straightforward integration.\n- ⚡ **Event-Driven Workflows**: Build extensible and dynamic workflows driven by events. This approach ensures flexibility and adaptability for automating complex processes.\n- 🧩 **Composable Architecture**: Create sophisticated systems by combining simple, reusable components. The framework’s modular design encourages clean and maintainable code.\n\n## Getting Started\n\nAdd swarm to go mod by:\n\n```shell\ngo get -u github.com/feiskyer/swarm-go\n```\n\n## Examples\n\nSetup environment variables first:\n\n- For OpenAI, set OPENAI_API_KEY and optional OPENAI_API_BASE for OpenAI API compatible AI service.\n- For Azure OpenAI, set AZURE_OPENAI_API_KE and AZURE_OPENAI_API_BASE.\n\n\u003cdetails\u003e\n\u003csummary\u003eBasic Agent\u003c/summary\u003e\n\nA [basic agent](demo/basic/) with function calls:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"reflect\"\n\n    \"github.com/feiskyer/swarm-go\"\n)\n\nfunc main() {\n    // Create a new agent\n    agent := swarm.NewAgent(\"Assistant\")\n    agent.WithModel(\"gpt-4o\").\n        WithInstructions(\"You are a helpful assistant.\")\n\n    // Example function that the agent can call\n    weatherFunc := swarm.NewAgentFunction(\n        \"getWeather\",\n        \"Get the current weather for a given location. Requires a location parameter.\",\n        func(args map[string]interface{}) (interface{}, error) {\n            location, ok := args[\"location\"].(string)\n            if !ok {\n                return nil, fmt.Errorf(\"location not provided\")\n            }\n            return fmt.Sprintf(\"The weather in %s is sunny\", location), nil\n        },\n        []swarm.Parameter{{Name: \"location\", Type: reflect.TypeOf(\"string\")}},\n    )\n\n    // Add function to agent\n    agent.AddFunction(weatherFunc)\n\n    // Run the demo loop\n    swarm.RunDemoLoop(agent, nil, false, false)\n}\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eStreaming Output\u003c/summary\u003e\n\nUse [streaming output](demo/streaming/) for your agent:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"reflect\"\n\n    \"github.com/feiskyer/swarm-go\"\n)\n\nfunc main() {\n    // Create a new agent\n    agent := swarm.NewAgent(\"Assistant\")\n    agent.WithModel(\"gpt-4o\").\n        WithInstructions(\"You are a helpful assistant.\")\n\n    // Example function that the agent can call\n    weatherFunc := func(args map[string]interface{}) (interface{}, error) {\n        location, ok := args[\"location\"].(string)\n        if !ok {\n            return nil, fmt.Errorf(\"location not provided\")\n        }\n        return fmt.Sprintf(\"The weather in %s is sunny\", location), nil\n    }\n\n    // Add function to agent\n    agent.AddFunction(swarm.NewAgentFunction(\n        \"getWeather\",\n        \"Get the current weather for a given location. Requires a location parameter.\",\n        weatherFunc,\n        []swarm.Parameter{{Name: \"location\", Type: reflect.TypeOf(\"string\")}},\n    ))\n\n    // Run the demo loop\n    swarm.RunDemoLoop(agent, nil, true, false)\n}\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eMulti-agent handoff\u003c/summary\u003e\n\n[Handoff example](demo/handoff/) for multiple agents:\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"os\"\n\n    \"github.com/feiskyer/swarm-go\"\n)\n\nfunc main() {\n    client := swarm.NewSwarm(swarm.NewOpenAIClient(os.Getenv(\"OPENAI_API_KEY\")))\n\n    englishAgent := swarm.NewAgent(\"English Agent\").WithInstructions(\"You only speak English.\")\n    spanishAgent := swarm.NewAgent(\"Spanish Agent\").WithInstructions(\"You only speak Spanish.\")\n\n    transferToSpanishAgent := swarm.NewAgentFunction(\n        \"transferToSpanishAgent\",\n        \"Transfer spanish speaking users immediately.\",\n        func(args map[string]interface{}) (interface{}, error) {\n            return spanishAgent, nil\n        },\n        []swarm.Parameter{},\n    )\n    englishAgent.AddFunction(transferToSpanishAgent)\n\n    messages := []map[string]interface{}{\n        {\n            \"role\":    \"user\",\n            \"content\": \"Hola. ¿Como estás?\",\n        },\n    }\n    response, err := client.Run(context.TODO(), englishAgent, messages, nil, \"gpt-4o\", false, true, 10, true)\n    if err != nil {\n        fmt.Println(err)\n        return\n    }\n    fmt.Println(response.Messages[len(response.Messages)-1][\"content\"])\n}\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eSimple Workflow\u003c/summary\u003e\n\nUse [sequential simple workflow](demo/simple/).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eFlexible Workflow\u003c/summary\u003e\n\nUse [flexible workflow](demo/joke/) for event-driven multi-agent orchestration.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eFlexible workflow with parallel tasks\u003c/summary\u003e\n\nUse flexible workflow for event-driven multi-agent orchestration with [parallel tasks](demo/novel/).\n\n\u003c/details\u003e\n\n## Contribution\n\nThe project is opensourced at github [feiskyer/swarm-go](https://github.com/feiskyer/swarm-go) with MIT License.\n\nIf you would like to contribute to the project, please follow these guidelines:\n\n1. Fork the repository and clone it to your local machine.\n2. Create a new branch for your changes.\n3. Make your changes and commit them with a descriptive commit message.\n4. Push your changes to your forked repository.\n5. Open a pull request to the main repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeiskyer%2Fswarm-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffeiskyer%2Fswarm-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeiskyer%2Fswarm-go/lists"}