ContractCoding is a contract-driven multi-agent collaboration paradigm that enables parallel programming and understands the operating principles of the entire system.
- ContractCoding/: The core framework code.
agents/: Agent implementations.engine.py: The main engine that orchestrates the workflow.runner.py: Executes individual agents.traverser.py: Manages the graph traversal.memory/: Memory and document management.prompts/: System and agent prompts.tools/: Available tools for agents.llm/: LLM client and utilities.
- examples/: Example scripts and usage.
- main.py: CLI entry point.
pip install -r requirements.txtTo add a new agent, create a new file in the agents/ directory. The agent should inherit from the BaseAgent class and implement the run method.
from ContractCoding.agents.base import BaseAgent
class MyAgent(BaseAgent):
def run(self, task: str) -> str:
# Implement the agent's logic here
return f"Executing task: {task}"Add the agent to the register_agent function in ContractCoding/engine.py.
from ContractCoding.config import Config
from ContractCoding.orchestration.engine import Engine
from ContractCoding.agents.forge import AgentForge
config = Config()
agent_forge = AgentForge(config)
contractcoding = Engine(config)
agent_forge.create_agent("My_Agent", MyAgent)
contractcoding.register_agent("My_Agent", MyAgent)result = contractcoding.run("Your task description")
print(result)To run the ContractCoding engine, use the following command:
python main.py --task "Your task description"Replace "Your task description" with the actual task you want the system to perform.
Run the engine with a task:
python main.py --task "Write a Gomoku program with AI that allows players to play against AI"