The only thing missing now is your Lead Detective Agent. This agent will then use the information retrieved from the other two agents to solve the crime and determine the value of the stolen items.
👉 Navigate to /project/Python/starter-project/config/agents.yaml
👉 Add the configuration for the Lead Detective Agent below your other agent.
lead_detective_agent:
role: >
Lead Detective Agent
goal: >
Solve the crime by determining which of the three suspects stole the painting.
backstory: >
You are a lead detective, solving burglaries.
llm: sap/gpt-4o👉 Navigate to /project/Python/starter-project/config/tasks.yaml
👉 Add the configuration for the solve crime for your new Lead Detective Agent.
solve_crime:
description: >
Find the thief among the suspects by activating the evidence analyst agent and instructing them to look for information on each of the three suspects
using the grounding tool. They should find information on alibis and motives and return a report for you to analyze.
expected_output: >
The name of the thief and the total value of the stolen goods for the insurance.
agent: lead_detective_agent👉 Add this code to your project/Python/starter-project/investigator_crew.py
@task
def solve_crime(self) -> Task:
return Task(
config=self.tasks_config['solve_crime'],
context=[self.appraise_loss_task(), self.analyze_evidence_task()] # this line will make sure that the other to agents run their tasks beforehand and the lead detective can use the output of those tasks.
)
@agent
def lead_detective_agent(self) -> Agent:
return Agent(
config=self.agents_config['lead_detective_agent'],
verbose=True
)👉 Update your crew in project/Python/starter-project/investigator_crew.py to run the tasks sequentially by adding the process line below:
@crew
def crew(self) -> Crew:
return Crew(
agents=self.agents, # Automatically collected by the @agent decorator
tasks=self.tasks, # Automatically collected by the @task decorator.
process=Process.sequential,
verbose=True
)👉 Ensure your main() function kicks off the crew with the appropriate inputs.
👉 Run your crew!
python project/Python/starter-project/main.py👉 Call for the instructor and tell them your suspect.
👉 Is it correct? If yes: Congratulations!, if not: Update your prompt and try again.
You created a complete multi-agent system where:
- The Lead Detective Agent orchestrates the investigation by delegating tasks
- The Evidence Analyst Agent retrieves and analyzes evidence from documents
- The Loss Appraiser Agent predicts financial values of stolen items
- Agent Communication flows through task delegation and result aggregation
- Reasoning Integration combines evidence, alibis, motives, and values to solve the crime
Lead Detective → Evidence Analysis → Grounding Search → Suspect Investigation
↓
Loss Appraisal → RPT-1 Predictions → Value Determination
↓
Crime Resolution → Suspect Identification → Final Report
Multi-agent systems are powerful because they:
- Distribute Responsibilities across specialized agents with distinct roles
- Enable Collaboration through task delegation and information sharing
- Improve Reasoning by combining multiple expert perspectives
- Handle Complexity by breaking down large problems into manageable subtasks
- Scale Efficiently as new agents and tools can be added without disrupting existing ones
- Multi-Agent Systems decompose complex problems into specialized, collaborative agents
- Sequential Processing allows agents to work in order, with later agents using earlier results
- Task Delegation allows agents to coordinate work and share results through the CrewAI framework
- Tool Integration across multiple agents (RPT-1, Grounding Service) provides comprehensive capabilities
- Agent Prompts must be carefully crafted to guide reasoning and ensure correct tool usage
- Crew Orchestration handles sequencing, communication, and result aggregation between agents
- Iterative Refinement of agent prompts and task descriptions improves investigation accuracy
In the following exercises, you will:
- ✅ Build a basic agent
- ✅ Add custom tools to your agents so they can access external data
- ✅ Create a complete crew with multiple agents working together
- ✅ Integrate the Grounding Service for better reasoning and fact-checking
- ✅ Solve the museum art theft mystery using your fully-featured agent team (this exercise)
Congratulations on completing the CodeJam! You've successfully built a sophisticated multi-agent AI system that can:
- Analyze evidence from documents
- Predict financial values using the SAP-RPT-1 model
- Coordinate between multiple specialized agents
- Solve complex real-world problems through collaborative reasoning
Issue: Agent is not using the Grounding Service tool
- Solution: Ensure the Evidence Analyst Agent has
tools=[call_grounding_service]in its definition and the task description explicitly mentions searching for evidence
Issue: Lead Detective Agent doesn't delegate to other agents
- Solution: Verify that:
- All agents are included in the crew:
agents=[appraiser_agent, evidence_analyst_agent, lead_detective_agent] - Tasks are assigned to the correct agents
- Task descriptions clearly indicate which agents should be consulted
- All agents are included in the crew:
Issue: RPT-1 tool is not returning predictions
- Solution: Ensure:
- The Loss Appraiser Agent has
tools=[call_rpt1]assigned - Your
.envfile contains valid RPT-1 deployment URL and credentials - The payload structure matches the RPT-1 API specification
- The Loss Appraiser Agent has
Issue: Grounding search returns no relevant documents
- Solution: Check that:
- The pipeline ID is correct
- Documents are properly indexed in SAP AI Launchpad
- Your search query is descriptive and targets the right evidence type
- The
maxChunkCountparameter is appropriate
Issue: Agents not executing in order or parallel execution
- Solution: Ensure you've set
process=Process.sequentialin your@crewmethod. UseProcess.hierarchicalif you need a manager agent to coordinate.
Issue: Agent is hallucinating or not finding the correct suspect
- Solution: Refine your Lead Detective Agent's prompt to:
- Be more specific about what evidence to look for
- Include explicit instructions to cross-reference alibis and motives
- Ask the agent to provide reasoning before concluding
- Consider adjusting the task description to guide the investigation more clearly
Issue: CrewAI raises errors about task assignment or agent delegation
- Solution: Verify that:
- All task configurations in
tasks.yamlmatch task method names - All agent configurations in
agents.yamlmatch agent method names - Tasks are assigned to agents using the
agentfield in the YAML - The crew includes all agents in the correct order
- All task configurations in