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_agentNow you'll add the Lead Detective Agent and its task to your investigator crew. This agent will coordinate the investigation by using results from the other agents.
👉 Open /project/Python/starter-project/investigator_crew.py
👉 Inside the InvestigatorCrew class, add the new agent and task methods after the existing analyze_evidence_task method and before the @crew method:
@agent
def lead_detective_agent(self) -> Agent:
return Agent(
config=self.agents_config['lead_detective_agent'],
verbose=True
)
@task
def solve_crime(self) -> Task:
return Task(
config=self.tasks_config['solve_crime'],
context=[self.appraise_loss_task(), self.analyze_evidence_task()] # 👈 Lead detective uses results from other tasks
)💡 Where to place this code: Add these methods inside the
InvestigatorCrewclass, after youranalyze_evidence_task()method. The final order should be:
appraiser_agent()methodappraise_loss_task()methodevidence_analyst_agent()methodanalyze_evidence_task()method- 👈 Add
lead_detective_agent()here- 👈 Add
solve_crime()herecrew()method (keep at the end)
💡 Understanding the
contextparameter:
context=[self.appraise_loss_task(), self.analyze_evidence_task()]tells CrewAI that thesolve_crimetask depends on the other two tasks- The Lead Detective will receive the output from both the Loss Appraiser and Evidence Analyst
- This enables the detective to combine financial predictions with evidence analysis to solve the crime
Your crew configuration should already be set from Exercise 04, but let's verify it's correct.
👉 In /project/Python/starter-project/investigator_crew.py, check that your @crew method looks like this:
@crew
def crew(self) -> Crew:
return Crew(
agents=self.agents, # Automatically collected by @agent decorator (all 3 agents)
tasks=self.tasks, # Automatically collected by @task decorator (all 3 tasks)
process=Process.sequential, # Tasks run in order: appraise → analyze → solve
verbose=True # Print detailed execution logs
)✅ If this is already in your file, you're good! CrewAI will automatically collect all decorated agents and tasks.
Your main.py from Exercise 04 should already be correct. It doesn't need any changes for Exercise 06!
💡 What's happening: The same
main.pythat ran 2 agents in Exercise 04 will now automatically run all 3 agents (including your new Lead Detective). CrewAI collects all@agentand@taskdecorated methods automatically.
👉 (Optional) Double-check your /project/Python/starter-project/main.py has both required inputs:
result = InvestigatorCrew().crew().kickoff(inputs={
'payload': payload,
'suspect_names': "Sophie Dubois, Marcus Chen, Viktor Petrov"
})✅ If you see these two inputs, you're all set—no changes needed!
👉 Run your crew to start the investigation!
python project/Python/starter-project/main.py⏱️ This may take 2-5 minutes as your agents:
- Search evidence documents for each suspect
- Predict values of stolen items using RPT-1
- Analyze findings and identify the culprit
👉 Review the final output—who does your Lead Detective identify as the thief?
👉 Call for the instructor and share your suspect.
If your Lead Detective identifies the wrong suspect, you'll need to refine your agent prompts to improve their reasoning.
Which prompts to adjust:
-
Lead Detective's Goal (
config/agents.yaml)- Make it more specific about what evidence to prioritize
- Example: Add "Focus on alibis, financial motives, and access to the museum"
-
Lead Detective's Task Description (
config/tasks.yaml)- Add explicit steps for analysis
- Example: "Compare each suspect's alibi against security logs. Identify who had opportunity, means, and motive."
-
Evidence Analyst's Task (
config/tasks.yaml)- Ensure it searches thoroughly for each suspect
- Example: "For each suspect, search for: alibi verification, financial records, access logs, and connections"
Tips for improving prompts:
- ✅ Be specific about what to analyze (alibi, motive, opportunity)
- ✅ Ask agents to cite specific documents
- ✅ Request cross-referencing of information
- ✅ Instruct agents to explain their reasoning step-by-step
- ❌ Avoid vague instructions like "solve the crime" without guidance
- ❌ Don't assume agents know which evidence is most important
👉 After updating prompts in the YAML files, run python project/Python/starter-project/main.py again
👉 Verify the answer with the instructor
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: AttributeError: 'NoneType' object has no attribute 'get' when running main.py
- Solution: This error occurs when YAML configuration has incorrect indentation. Check your
config/tasks.yamlfile and ensure all fields (description,expected_output,agent) are indented with 2 spaces under each task name:solve_crime: description: > # ← Must be indented 2 spaces Your task description expected_output: > # ← Must be indented 2 spaces Expected output agent: lead_detective_agent # ← Must be indented 2 spaces
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