SAP-samples/btp-joule-a2a-pro-code-agent
A reference Agent-to-Agent implementation on SAP BTP that lets Joule delegate sales-quotation optimisation to a CAP pro-code agent using SAP-RPT-1 for forecasting.
A CAP agent built with LangGraph and the SAP Cloud SDK for AI implements the Agent-to-Agent protocol so that Joule can delegate a task to it as a third-party agent rather than call a fixed skill. The worked example is a Sales Optimization Agent: given a sales inquiry, it fetches payment terms and discounts, generates several fictional quotations, and scores them with the SAP-RPT-1 forecasting model on conversion probability, payment delay and a win-versus-customer-win rating before returning the top three to the user in Joule. A webhook server handles asynchronous push notifications for tasks that run long, and Terraform scripts provision the full BTP landscape: subaccount, Cloud Foundry, IAS trust, Joule, AI Core and HANA.
Facts
Where it sits
Who is behind it
In the atlas: maintains 222@SAP-samplesmaintainerjulian-schambeckContributes to this
In the atlas: contributes to 6@julian-schambeckKay SchmitteckertContributes to this
In the atlas: contributes to 6@kay-schmitteckertmar-holContributes to this
In the atlas: contributes to 2@mar-holRobinContributes to this
In the atlas: contributes to 3@RobinPurschwitz4 contributors
What it declares
Every artifact
- Type
- Sample
- Origin
- By SAP
- Use as
- A reference
As a sample
- Form
- A reference application
Connections
Building an agent into your own application
Download
Architecture
as 2 deployment descriptors state it at 28a2883, readDownload
Bound, and not drawn
- code-based-agent-srvSAP AI Core, SAP Destination service, SAP Application Logging service for SAP BTP
Documented, with no instance in the document
- @sap/xssec requires SAP Authorization and Trust Management servicecode-based-agent-srv
- @sap/xssec requires Cloud Identity Servicescode-based-agent-srv
Download
Documented, with no instance in the document
- @sap/approuter requires Cloud Identity Serviceswebhook-cap-routerAuthenticating the user against Identity Authentication instead of, or alongside, SAP Authorization and Trust Management service. Bound to both, the router picks IAS.@sap/approuter 23.0.0 — README, authenticationType
Bound to both services: prefers ias if both authentication services can be used in the current subaccount, determined via BTP security endpoint (may impact response time)
- @sap/approuter requires SAP Destination servicewebhook-cap-routerReading the destination a route forwards to, where that configuration is not written into the router's own environment.@sap/approuter 23.0.0 — README, destination configuration
Destination configuration can also be read from `destination service`.
- @sap/approuter requires SAP Connectivity servicewebhook-cap-routerForwarding to an on-premise backend: the binding is required once a destination sets its ProxyType to on-premise.@sap/approuter 23.0.0 — README, destination ProxyType
if ProxyType set to `on-premise`, binding to SAP Cloud Platform connectivity service is required.
- @sap/approuter requires SAP HTML5 Application Repository service for SAP BTPwebhook-cap-routerServing static content from the repository rather than from the router's own folder. Bound, both the files and the xs-app.json routes come from there.@sap/approuter 23.0.0 — README, Integration with HTML5 Application Repository
When the application router interacts with HTML5 Application Repository to serve HTML5 Applications, all static content and routes (xs-app.json) are retrieved from HTML5 Application Repository.
- @sap/xssec requires Cloud Identity Serviceswebhook-cap-srv
README
quoted from SAP-samples/btp-joule-a2a-pro-code-agent under Apache-2.0, readReference Implementation for A2A-Compliant Pro-Code Agents on SAP BTP with Joule Integration and RPT-1
Modular reference implementation covering a full-fledged agentic scenario end to end including Joule Integration via the A2A Protocol.
📖 Introduction & Purpose
This repository serves as a reference implementation for building enterprise-grade, "Pro-Code" Agents on the SAP Business Technology Platform (BTP). It demonstrates a modular, full-fledged agentic scenario from end-to-end, adhering to best practices for BTP development.
The primary goals of this project are:
- A2A Compliance: Implementing Agent-to-Agent (A2A) Protocol compliant agents ("3rd Party Agents") to set scope, identify specification gaps, and contribute upstream fixes.
- Joule Integration: Facilitating outbound A2A integration where Joule acts as the client for BTP-hosted or remotely hosted 3rd party agents.
- Leveraging SAP-RPT-1 to run use cases like forecasting (e.g., Payment Delay, New Product Introduction) or simulation.
🏗️ Architecture

This simplified architecture is enhanced with access to RPT-1 as a tool and is based on reference architectures from the SAP Architecture Center: Integrating AI Agents with Joule and Pro-Code AI Agents on SAP BTP.
✨ Features
The project features are organized by status, ranging from core A2A compliance to advanced integrations.
| Feature / Module | Status | Description |
|---|---|---|
| A2A-Compliant Agent | ✅ Done | Full implementation of the A2A protocol specifications, capable of handling complex agentic workflows. |
| Pro-Code AI Agent Implementation | ✅ Done | Built using LangGraph (TypeScript) on CAP, integrated with the SAP Cloud SDK for AI to access models via the Generative AI Hub. Includes Human-in-the-Loop patterns. |
| Joule Integration (A2A) | ✅ Done | Integration into Joule via the A2A protocol |
| Asynchronous Communication | ✅ Done | Implementation of Webhooks for A2A PushNotifications. Includes a WebSocket-based server and React UI to visualize status updates as they arrive. |
| Extension Sample | ✅ Done | Examples of custom logic extensions (e.g., mocking responses) to bypass LLM generation for testing or specific logic handling. |
| Advanced Forecasting | ✅ Done | Leveraging SAP-RPT-1 to run use cases like forecasting (e.g., Payment Delay, New Product Introduction) or simulation. |
| Infrastructure as Code | ✅ Done | Full E2E setup via Terraform. |
🛠️ Tech Stack & References
- Infrastructure:
- Frameworks:
- SAP Cloud Application Programming Model (CAP)
- LangGraph JS (Agent Framework)
- Protocol: A2A Protocol Spec
- SDKs:
📂 Project Structure
The repository is organized into modular components to simulate a distributed agent environment:
| Directory | Description |
|---|---|
a2a-agent | The core Pro-Code Agent. • Written in TypeScript on CAP. • Uses LangGraph for agent logic. • A2A Compliant. • Connects to Generative AI Hub via SAP Cloud SDK for AI. |
joule-integration | Connecting Joule via the A2A protocol to the a2a-agent using action type agent-request. |
webhook-server | A WebSocket-based CAP server for handling A2A PushNotifications. • Backend (CAP): Receives StatusUpdates from the agent.• Frontend (React.js): Displays incoming status updates live. |
terraform | Infrastructure as Code for full E2E BTP setup. • Provisions subaccount, Cloud Foundry, IAS trust, Joule, AI Core, HANA, and all service bindings. • Uses SAP BTP, Cloud Foundry, and SCI Terraform providers. |
🚦 Getting Started
💡 Use Case: AI-Assisted Sales Inquiry Optimization

User Story
As a Sales User at BestRun, I want to use the Joule AI Copilot to automatically analyze, generate, and score optimized sales quotation options for incoming customer inquiries, So that I can maximize the sales conversion probability, balance profitability, and respond to customers (like Altinova) faster with the best possible terms.
Acceptance Criteria
- The Sales User can trigger the optimization directly from the Task Center via Joule.
- Joule must automatically identify and delegate the request to the specific Sales Optimization Agent (SOA) via A2A protocol.
- The SOA must auto-retrieve necessary data (Payment Terms, Discounts) and generate multiple fictional sales quotations.
- The system must use the RPT-1 forecasting model to score these quotations based on Conversion Probability, Payment Delay, and a "Win/Win" rating.
- The user is presented with the Top 3 distinct quotation options with reasoning for manual finalization.
Use Case Specification
Use Case Name: Optimize Sales Inquiry via Agent-to-Agent (A2A) Delegation
Actors
- Sales User (SU)
- Joule: The AI Assistant.
- Sales Optimization Agent (SOA): The backend autonomous agent.
- Customer (Altinova): Trigger entity (sender of inquiry).
Preconditions
- A new Sales Inquiry from Customer "Altinova" exists in the system.
- The Sales Inquiry appears as an open item in the SU’s Task Center.
- The SU has permissions to access Joule and Sales tools.
Main Success Scenario (Happy Path)
| Step | Actor | Action |
|---|---|---|
| 1 | System | Displays a notification/dot in the Task Center indicating a new Sales Inquiry from Altinova. |
| 2 | SU | Opens Joule (AI Copilot) and inputs the command: "Please optimize the latest Sales Inquiry from Customer Altinova." |
| 3 | Joule | Analyzes the intent and available assets. Identifies the Sales Optimization Agent (SOA) as the suitable tool. |
| 4 | Joule | Initiates Agent-to-Agent (A2A) handover and transmits the task to the SOA. |
| 5 | SOA | Accepts the task and verifies context. Validates that the Inquiry ID and Customer Name are available. |
| 6 | SOA | Tool Execution: Retrieves available data assets (Payment Terms, applicable Discounts, Master Data). |
| 7 | SOA | Tool Execution: Uses createFictionalSalesQuotations to generate multiple combinatorial variants of the quotation. |
| 8 | SOA | Reasoning: Applies the Forecasting Model RPT-1 (in-context learning) to evaluate the variants based on: Sales Conversion Probability, Expected Payment Delay, Rating (Win vs. Customer Win). |
| 9 | SOA | Selects the Top 3 best-performing fictional quotations. |
| 10 | Joule | Displays the Top 3 options to the SU, including the reasoning/score for each. |
| 11 | SU | Reviews the options and selects/refines the preferred quotation for creation. |
Alternative Flows
A1. Missing Data (Step 5)
- If the SOA detects missing details (e.g., Sales Inquiry ID is ambiguous), it halts the automatic flow.
- SOA/Joule asks the SU a clarifying question to retrieve the missing information.
- Once answered, the flow resumes at Step 6.
A2. Long Processing Time (Step 7-9)
- If the combinatorics or RPT-1 model processing takes longer than the standard interaction threshold:
- Joule informs the SU that the calculation is running in the background.
- System sends a Push Notification to the SU once the Top 3 options are ready for review.
👥 Contributors & Contacts
- Dziwisch, Niklas niklas.dziwisch@sap.com
- Gonzalez, Johanna johanna.gonzalez@sap.com
- Pleyer, Adi adi.pleyer@sap.com
- Purschwitz, Robin robin.purschwitz@sap.com
- Radulescu, Sorin sorin.radulescu@sap.com
- Schambeck, Julian julian.schambeck@sap.com
- Schmitteckert, Kay kay.schmitteckert@sap.com
- Thimmiaha, Vikas vikas.thimmiaha@sap.com
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
Contributors
History in the atlas
- First seen.
For your agent
- Ref
artifact:sap-samples-btp-joule-a2a-pro-code-agent- JSON
- /artifacts/sap-samples-btp-joule-a2a-pro-code-agent.json
- MCP
- Connecting an agent