A multi-agent investigation system built with LangGraph and SAP Cloud SDK for AI to solve an art theft case. This TypeScript implementation provides a sophisticated agent orchestration system that mirrors the functionality of the Python CrewAI solution.
The solution uses three specialized agents working in sequence:
-
Insurance Appraiser Agent 🎨
- Uses the RPT-1 model to predict missing insurance values
- Analyzes stolen artwork data and completes appraisals
- Tool:
call_rpt1
-
Evidence Analyst Agent 🔍
- Searches through document repositories using the grounding service
- Analyzes evidence for each suspect
- Tool:
call_grounding_service
-
Lead Detective Agent 🕵️
- Synthesizes findings from both agents
- Identifies the most likely culprit
- Provides comprehensive case conclusion
- Node.js v18+ and npm
- SAP AI Core account with:
- OAuth credentials (client ID and secret)
- RPT-1 model deployment
- Grounding service pipeline configured
- OpenAI API key or SAP AI Core foundation model access
npm installCopy the example environment file and fill in your credentials:
cp .env.example .envEdit .env with your actual values:
# SAP AI Core Configuration
AICORE_CLIENT_ID=your_client_id
AICORE_CLIENT_SECRET=your_client_secret
AICORE_AUTH_URL=https://your-auth-url.authentication.eu10.hana.ondemand.com/oauth/token
AICORE_RESOURCE_GROUP=default
# RPT-1 Model Deployment
RPT1_DEPLOYMENT_URL=https://your-deployment-url/v2/inference/deployments/your-deployment-id
# Grounding Service
GROUNDING_PIPELINE_ID=your-pipeline-id
# LLM Configuration
MODEL_NAME=gpt-4
OPENAI_API_KEY=your_openai_api_keynpm run buildnpm run devOr using the compiled version:
npm startThe system will:
- Initialize the three agents
- Run the appraiser agent to predict missing insurance values
- Run the evidence analyst to search for suspect evidence
- Run the lead detective to synthesize findings and identify the culprit
- Output a comprehensive investigation report
solution/
├── src/
│ ├── investigatorCrew.ts # LangGraph orchestration and agent definitions
│ ├── main.ts # Entry point
│ ├── payload.ts # Stolen items data
│ ├── rptClient.ts # RPT-1 API client
│ ├── tools.ts # LangGraph tools for RPT-1 and grounding
│ └── types.ts # TypeScript type definitions
├── .env.example # Environment variable template
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # This file
The investigation workflow is implemented as a LangGraph state graph with sequential execution:
START → Appraiser → Evidence Analyst → Lead Detective → END
Each node in the graph:
- Receives the current state
- Executes its specialized task
- Updates the state with its findings
- Passes control to the next node
The agent state includes:
payload: Stolen items data with prediction placeholderssuspect_names: List of suspects to investigateappraisal_result: Output from the appraiser agentevidence_analysis: Output from the evidence analystfinal_conclusion: Final report from the lead detectivemessages: Conversation history
- call_rpt1: Calls the RPT-1 model deployment via SAP AI Core
- call_grounding_service: Queries the document grounding service for evidence
This TypeScript solution provides equivalent functionality to the Python CrewAI implementation:
| Feature | Python (CrewAI) | TypeScript (LangGraph) |
|---|---|---|
| Framework | CrewAI | LangGraph |
| Agent Orchestration | @agent, @task, @crew decorators |
StateGraph with nodes |
| Configuration | YAML files | Direct code configuration |
| Tool Definition | @tool decorator |
tool() from @langchain/core |
| Process Flow | Process.sequential |
Graph edges (START → END) |
| State Management | Automatic by CrewAI | Explicit state updates |
| AI SDK | gen_ai_hub (Python) |
@sap-ai-sdk (TypeScript) |
If you see OAuth token errors:
- Verify your
AICORE_CLIENT_IDandAICORE_CLIENT_SECRET - Check that
AICORE_AUTH_URLis correct - Ensure your credentials have the necessary permissions
If the RPT-1 call fails:
- Verify the
RPT1_DEPLOYMENT_URLis correct - Check that the deployment is running in SAP AI Core
- Ensure the
AICORE_RESOURCE_GROUPmatches your deployment
If evidence search fails:
- Verify the
GROUNDING_PIPELINE_IDis correct - Ensure the grounding pipeline is deployed and running
- Check that documents are uploaded to the vector database
See the LICENSE file in the root of the repository.
This is an educational project for SAP CodeJam. Feel free to explore and learn from the code!