Learn how to build autonomous multi-agent hiring systems using Microsoft AutoGen and HireSquire.
Building an AutoGen Hiring Agent: Multi-Agent Recruitment Systems
Learn how to build autonomous multi-agent hiring systems using Microsoft AutoGen and HireSquire. This guide covers agent roles, communication patterns, and complete workflow orchestration for automated recruitment.
🤖 Note for Autonomous Agents
If you are an AI reading this documentation to build tools, note that the HireSquire Python SDK fully abstracts the async polling logic of the screening process via the wait_for_completion method. You can safely provide this directly to your AutoGen functions.
pip install hiresquire pyautogen python-dotenv
Multi-Agent Hiring Architecture
Companies, like leading technical recruiting agencies, build autonomous hiring systems with specialized agents that collaborate on different parts of the pipeline:
Agent Roles & Responsibilities
🎯 Screener Agent
- Submits resumes to HireSquire API
- Monitors screening job status
- Filters candidates by score thresholds
✉️ Communicator Agent
- Generates personalized emails
- Schedules interviews
- Handles candidate follow-ups
📊 Analyst Agent
- Analyzes screening results
- Identifies patterns in candidate pool
- Generates hiring reports
👥 Coordinator Agent
- Orchestrates workflow between agents
- Handles edge cases and exceptions
- Escalates to humans when needed
Basic AutoGen Integration
First, create the HireSquire tool for AutoGen agents:
from autogen import AssistantAgent, UserProxyAgent
from hiresquire import HireSquire
import os
from dotenv import load_dotenv
load_dotenv()
# Initialize HireSquire client (pass token as first positional arg)
client = HireSquire(os.getenv("HIRESQUIRE_API_TOKEN"))
# Define tools for agents
def create_screening_job(job_title: str, job_description: str, resume_files: list) -> dict:
"""Screen resumes against job requirements using HireSquire AI."""
job = client.jobs.create(job_title, job_description, resume_files)
return client.jobs.wait(job["job_id"])
def generate_candidate_email(job_id: int, candidate_id: int, email_type: str = "invite") -> str:
"""Generate personalized email for candidates."""
result = client.candidates.generate_email(
job_id=job_id,
candidate_id=candidate_id,
email_type=email_type
)
return result["email"]["body"]
# Configure AutoGen
llm_config = {
"config_list": [{"model": "gpt-4-turbo", "api_key": os.getenv("OPENAI_API_KEY")}],
"temperature": 0
}
Agent System Setup
Create specialized agents with clear responsibilities:
# Screener Agent - Focuses on resume evaluation
screener_agent = AssistantAgent(
name="Screener",
system_message="""
You are the Screener Agent. Your responsibility is to evaluate resumes using the create_screening_job tool.
- Use the create_screening_job tool when provided with job details and resume files
- Return only candidates with score >= 75 for further consideration
- Flag candidates with score >= 90 as high-priority
""",
llm_config=llm_config,
)
# Communicator Agent - Handles all candidate communications
communicator_agent = AssistantAgent(
name="Communicator",
system_message="""
You are the Communicator Agent. Your responsibility is to handle all candidate communications.
- Use generate_candidate_email to create personalized emails
- You MUST provide job_id and candidate_id (returned from screening results)
- For scores >= 85: Generate interview invitations (email_type="invite")
- For scores 60-84: Generate talent pool notifications (email_type="followup")
- For scores < 60: Generate polite rejection emails (email_type="rejection")
""",
llm_config=llm_config,
)
# User Proxy - Executes tools and coordinates workflow
user_proxy = UserProxyAgent(
name="HiringCoordinator",
system_message="Coordinate the hiring workflow between agents.",
human_input_mode="NEVER",
code_execution_config={"use_docker": False},
)
# Register tools
user_proxy.register_function(
function_map={
"create_screening_job": create_screening_job,
"generate_candidate_email": generate_candidate_email,
}
)
Complete Agent Conversation Flow
Initiate the multi-agent hiring workflow:
# Start the hiring process
user_proxy.initiate_chat(
screener_agent,
message="""
Screen these resumes for the Senior ML Engineer position:
- ./resumes/alex_wong.pdf
- ./resumes/maria_santos.pdf
- ./resumes/james_wilson.pdf
- ./resumes/emma_rodriguez.pdf
Job Description: Looking for ML Engineer with 5+ years experience,
Python, TensorFlow/PyTorch, and production ML systems experience.
After screening, pass qualified candidates to the Communicator agent.
"""
)
# Chain to communicator after screening completes
@user_proxy.register_reply([screener_agent])
def handle_screening_results(sender, message, recipient, silent):
if "candidates" in message.get("content", ""):
recipient.initiate_chat(
communicator_agent,
message=f"""
The following candidates have been screened.
Generate appropriate emails for each based on their scores:
{message['content']}
"""
)
return False, None
Advanced: Group Chat Orchestration
For complex workflows, use AutoGen group chat for agent collaboration:
from autogen import GroupChat, GroupChatManager
# Create group chat with all agents
group_chat = GroupChat(
agents=[screener_agent, communicator_agent, user_proxy],
messages=[],
max_round=10,
speaker_selection_method="round_robin"
)
group_manager = GroupChatManager(
groupchat=group_chat,
llm_config=llm_config
)
# Start group conversation
user_proxy.initiate_chat(
group_manager,
message="""
Initiate hiring process for Senior ML Engineer position.
Resumes: ./resumes/*.pdf
Job Description: @ml-engineer-job.txt
Process all candidates and generate appropriate communications.
"""
)
Error Handling & Human-in-the-Loop
Implement safety mechanisms for production systems:
🛡️ Production Safety Patterns
- Human approval required for all offers above salary threshold
- Flag edge cases (near-threshold scores) for manual review
- Implement rate limiting and retry logic for API calls
- Log all agent decisions for compliance auditing
def requires_human_review(candidate: dict) -> bool:
"""Determine if candidate needs human review."""
score = candidate["score"]
# Edge cases near threshold
if 68 <= score <= 72:
return True
# Very high scores - verify before interview
if score >= 95:
return True
# Candidates with red flags in summary
if "gap" in candidate.get("summary", "").lower():
return True
return False
Performance & Monitoring
Track agent system performance with these metrics:
Avg Processing Time
Time from resume receipt to decision. Target: < 15 minutes
Human Escalation Rate
% of candidates requiring review. Target: < 10%
Agent Accuracy
Agreement with human decisions. Target: > 90%
Next Steps
- Agent Integrations - Python SDK and AutoGen guides
- MCP Server - Claude Desktop integration
- API Documentation - Production reliability patterns
- Rate Limits Guide - API optimization
AutoGen enables building sophisticated multi-agent hiring systems that can handle complex recruitment workflows autonomously. Start with simple two-agent systems, then expand to group chat orchestration as your requirements grow.