Skip to main content

Agent swarm orchestrator inspired by Moonshot AI's Kimi K2.5 model. Lightweight toolkit for coordinating autonomous agent swarms with 256K context window support.

Project description

AgentSwarm Orchestrator - Python Implementation

This Python implementation of AgentSwarm Orchestrator was inspired by https://kimik25.com. It provides a simple, intuitive API for managing autonomous agent swarms with async support.

Features

  • Simple API: Easy to use with Pythonic design patterns
  • Async Support: Built on asyncio for efficient concurrent operations
  • 256K Context: Inspired by Kimi K2.5's extended context window
  • Type Hints: Full type annotations for better IDE support
  • Dataclasses: Clean, structured data models

Installation

pip install kimi25-opensource

Usage

import asyncio
from agent_swarm import AgentSwarm, SwarmConfig, TaskMessage
import uuid

async def main():
    # Initialize swarm with 256K context window
    config = SwarmConfig(
        max_agents=100,
        context_window=256000,
        topology='mesh'
    )

    swarm = AgentSwarm(config)

    # Spawn specialized agents
    agent = swarm.spawn_agent('data-processor', 'analysis', 'transform')

    # Dispatch messages
    agent.dispatch_message(TaskMessage(
        id=str(uuid.uuid4()),
        msg_type='process',
        payload={'data': 'example'}
    ))

    # Get swarm statistics
    print(swarm.get_stats())

    # Clean shutdown
    await swarm.shutdown()

asyncio.run(main())

API Reference

Classes

SwarmConfig

Configuration dataclass for swarm initialization.

Parameters:

  • max_agents (int): Maximum number of agents (default: 100)
  • context_window (int): Token context limit (default: 256000)
  • topology (str): Swarm topology (default: 'mesh')

TaskMessage

Message dataclass for inter-agent communication.

Parameters:

  • id (str): Unique message identifier
  • msg_type (str): Message type
  • payload (Dict[str, Any]): Message data
  • from_agent (str): Source agent ID (auto-set)
  • to_agent (str): Target agent ID

Agent

Represents a single autonomous agent.

Methods:

  • dispatch_message(msg: TaskMessage) -> bool: Send a message
  • process_messages(handler: Callable) -> Awaitable: Process queued messages

AgentSwarm

Main swarm coordinator class.

Methods:

  • spawn_agent(agent_id: str, *capabilities) -> Agent: Create a new agent
  • broadcast_message(from_agent, msg_type, payload) -> int: Send to all agents
  • get_agent(agent_id: str) -> Agent: Retrieve agent by ID
  • get_stats() -> Dict: Get swarm statistics
  • shutdown() -> Awaitable: Gracefully shutdown

Enums

TopologyType

Supported swarm topologies:

  • HIERARCHICAL: Tree-based coordination
  • MESH: Peer-to-peer communication
  • HYBRID: Combined approach

Examples

Async Message Processing

import asyncio
from agent_swarm import AgentSwarm, SwarmConfig

async def message_handler(msg):
    print(f"Processing {msg.msg_type}")
    # Handle message asynchronously
    await asyncio.sleep(0.1)

async def main():
    swarm = AgentSwarm(SwarmConfig(max_agents=50))
    agent = swarm.spawn_agent('worker', 'processing')

    await agent.process_messages(message_handler)

asyncio.run(main())

Custom Topology

from agent_swarm import SwarmConfig, TopologyType

config = SwarmConfig(
    max_agents=200,
    context_window=512000,
    topology=TopologyType.HIERARCHICAL.value
)

Development

Running Tests

pip install -e ".[dev]"
pytest

Code Formatting

black agent_swarm/
mypy agent_swarm/

Performance

The Python implementation is optimized for:

  • Async I/O: Efficient concurrent operations via asyncio
  • Memory efficiency: Minimal overhead per agent
  • Developer productivity: Clean, readable code

Links

License

MIT License - See LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kimi25_opensource-1.0.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kimi25_opensource-1.0.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file kimi25_opensource-1.0.0.tar.gz.

File metadata

  • Download URL: kimi25_opensource-1.0.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for kimi25_opensource-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1b9641d987e9b8d8bd124107af94b18957ecf9e9f73976f78551b404c77ed714
MD5 9e11f64cadf9f702f501c544137897fd
BLAKE2b-256 626256e40cc7a19307c0dfa37ccd79399024130e4f373ec9ee954441f70d5d12

See more details on using hashes here.

File details

Details for the file kimi25_opensource-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for kimi25_opensource-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e328b44473b34a8d3e071aba062c5a80664bbc3cfc4f27fc89fc8a924b7ac87c
MD5 3902f9e18d07b8b232c2c011ff838945
BLAKE2b-256 f0cb16ebed6b509e6fac7a8e546e04d873b78d479133650087f5159d0cbfc217

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page