# Joule beside Microsoft 365 Copilot and other assistants

> Decide which assistant owns which task when Joule sits beside Microsoft 365 Copilot and other agents, and how the user's identity crosses between them.

- Course: Orchestrate, Unit 23 · Joule and the AI platform: the architect's view
- Page: https://erpfde.com/topics/joule-and-other-assistants/
- Updated: 2026-11-28
- Reading time: Foundational 8 min, Deep 35 min

Independent learning resource. Not affiliated with, sponsored by or endorsed by SAP SE. SAP and other SAP products mentioned are trademarks of SAP SE in Germany and other countries.

## Foundational layer

### The 60-second version

Most companies that run SAP also give their staff Microsoft 365 Copilot, and some use Gemini Enterprise or another assistant. People will ask SAP questions wherever they already work. So the question is not "Joule or Copilot", but **which assistant answers which question, and as whom**.

SAP offers two kinds of connection, as of November 2026:

1. **Joule and Microsoft 365 Copilot, both ways.** From Teams or Copilot you can reach Joule for SAP tasks; from Joule you can reach Microsoft 365 information such as email. SAP and Microsoft call this generally available since early 2026 ([SAP News](https://news.sap.com/2026/01/sap-business-ai-release-highlights-q4-2025/), [Microsoft](https://techcommunity.microsoft.com/blog/sapapplications/sap--microsoft-365-a-unified-ai-experience-that-works-where-you-work/4480380)).
2. **Agents talking to agents.** Another platform's agent (Copilot Studio, Gemini Enterprise, AWS) calls a Joule agent through SAP's Agent Gateway, or Joule calls an outside agent. This uses the open A2A protocol. SAP's own pages disagree on whether it is generally available yet ([SAP Architecture Center](https://architecture.learning.sap.com/news/2026/10/27/a2a-agent-gateway-interoperability)).

The rule that keeps this safe: **one owner per task, and SAP changes stay with SAP.** The user's own identity must reach SAP at every hop, never a shared account.

### Why it matters to the business

- **Adoption.** A clerk who lives in Teams will not open a second app to ask about a blocked order. Reaching Joule from Teams removes that step.
- **Duplicate answers.** If Copilot and Joule can both answer "which orders are blocked?", two people get two answers. Nobody knows which one is right, and support has two places to look.
- **Control.** SAP checks a user's authorizations for every action Joule takes. If another assistant changes SAP data through its own connection, that check can be skipped or made with a shared account. An auditor will ask who released a credit block; "the Copilot agent" is not an answer.
- **Cost.** Each side has its own meter. SAP's product page says AI Units are currently required for the Joule and Microsoft 365 Copilot feature ([SAP](https://www.sap.com/products/artificial-intelligence/joule-joule-and-microsoft-365-copilot.html)). Microsoft and SAP's joint post says you need Joule Base and a Microsoft 365 licence, and a Microsoft 365 Copilot licence only for Copilot skills used within Joule ([Microsoft](https://techcommunity.microsoft.com/blog/sapapplications/sap--microsoft-365-a-unified-ai-experience-that-works-where-you-work/4480380)). SAP's setup lesson lists a licensed Copilot environment as a prerequisite ([SAP Learning](https://learning.sap.com/courses/setting-up-joule-across-your-organizational-system-landscapes/setting-up-joule-with-microsoft-365-copilot)). Get both vendors to confirm in writing.

At the fictional Calder Pumpworks, customer service works in Teams, the credit analyst reads customer emails in Outlook and releases credit blocks in SAP, and the transport planner wants truck arrival times from a carrier's own agent. Each of those is a different owner.

### How SAP does it

- **Joule and Microsoft 365 Copilot.** SAP's lesson says the integration connects the two "without merging them", starts with Microsoft Teams, tells the user whether Joule or Copilot answered, and is opt-in for both products ([SAP Learning](https://learning.sap.com/courses/setting-up-joule-across-your-organizational-system-landscapes/setting-up-joule-with-microsoft-365-copilot)). Microsoft's post adds Word, PowerPoint, Excel and OneNote, and says Joule routes to Copilot when Microsoft 365 context is relevant ([Microsoft](https://techcommunity.microsoft.com/blog/sapapplications/sap--microsoft-365-a-unified-ai-experience-that-works-where-you-work/4480380)).
- **Identity across the two.** Users sign in with Microsoft Entra ID, which is federated with SAP Cloud Identity Services. An SAP expert's setup guide says Joule keeps a one-to-one relationship with an Entra ID tenant, so a test Joule needs its own test tenant ([SAP Community](https://community.sap.com/t5/technology-blog-posts-by-sap/enable-microsoft-copilot-and-teams-to-pass-requests-to-joule/ba-p/14109137)).
- **Copilot Studio to Joule agents.** SAP's reference architecture (23 October 2026) has a Copilot Studio agent hand SAP tasks to Joule agents through a custom connector and SAP's Agent Gateway, keeping the named user. It says the gateway is not yet GA ([SAP Architecture Center](https://architecture.learning.sap.com/docs/ref-arch/a2c0f1)). SAP's news post four days later announces GA of inbound A2A in October 2026 ([SAP Architecture Center news](https://architecture.learning.sap.com/news/2026/10/27/a2a-agent-gateway-interoperability)). Ask SAP which applies to your contract.
- **Gemini Enterprise.** The same pattern, with Gemini Enterprise as the assistant the user talks to and Joule agents doing the SAP part, also marked not yet GA ([SAP Architecture Center](https://architecture.learning.sap.com/docs/ref-arch/c9a3f8)).
- **Joule calling outside agents.** Joule can call an external agent over A2A and stay the orchestrator. SAP's page marks parts of this as not yet GA and expects an answer within 60 seconds ([SAP Architecture Center](https://architecture.learning.sap.com/docs/ref-arch/ae6821)).

### Who owns which task

A one-page ownership table is the main deliverable of this topic. Here is Calder's.

| Task | Where the user is | Owner | Why |
| --- | --- | --- | --- |
| Which of my orders are blocked? | Teams | Joule | SAP data, read within the clerk's SAP authorizations |
| Summarize Hallam's emails about the credit hold | Joule | Microsoft 365 Copilot | The emails live in Microsoft 365 |
| Draft a reply to Hallam | Outlook | Microsoft 365 Copilot | No SAP data needed |
| Release the credit block on an order | Teams | Joule, with confirmation | A change in SAP; only the credit analyst's role may do it |
| What is the next step on this blocked order? | Copilot Studio agent | Calder's order exceptions agent in Joule | The logic lives in SAP; Copilot Studio only asks |
| When does the truck arrive? | Joule | The carrier's agent | The carrier owns the answer; Joule asks it |

Three rules make the table: **the system that holds the data owns the answer**; **every change to SAP data goes through Joule's confirmation under an SAP role**; **each task has exactly one owner**, written down.

> **Note** **For functional consultants.** Roles now decide what people can do from Teams too, so test cases must cover the same request from Teams and from Joule. Add a test where a user without the credit release role asks from Teams: it must be refused. Mapping each Microsoft account to the right SAP user becomes part of user setup.

### Questions to ask

- Which tasks does each assistant own, and where is that written down?
- Are both Microsoft 365 Copilot and Joule licences, and SAP AI Units, confirmed in writing for the people who will use the integration?
- Does our test Joule have its own Entra ID tenant, separate from production?
- When another platform's agent calls a Joule agent, whose SAP user does SAP see? Show us the audit record.
- Is the Agent Gateway path generally available under our contract, or is it a pilot?
- Can any other assistant change SAP data without going through Joule's confirmation?

### Common misconceptions

- **"Joule in Teams replaces our own Copilot Studio agent."** Joule answers what its skills and agents cover. A Calder-specific agent is still yours to build; the integration only lets the two reach each other.
- **"If both assistants can answer, more coverage is better."** Two owners give two answers. Pick one.
- **"The other platform's agent can use a service account into SAP."** SAP's pattern needs a user token for invoking an SAP agent, and the user's authorizations apply ([SAP Architecture Center news](https://architecture.learning.sap.com/news/2026/10/27/a2a-agent-gateway-interoperability)).
- **"It's GA, so every part is GA."** The Joule and Microsoft 365 Copilot integration is GA; agent-to-agent pieces carry mixed labels on SAP's own pages.
- **"One Entra tenant can serve test and production Joule."** SAP's expert guide says the relationship is one to one.

### Key terms

- **Joule and Microsoft 365 Copilot integration:** SAP's opt-in, two-way link that lets each assistant reach the other's information, starting in Teams.
- **Microsoft Entra ID:** Microsoft's identity service where Calder's staff sign in.
- **SAP Cloud Identity Services:** SAP's identity service; it trusts Entra ID and maps each person to their SAP user.
- **A2A (Agent2Agent):** an open protocol for one agent to send work to another.
- **Agent Gateway:** SAP's single entry point where outside agents call Joule agents; it checks the token and an access list.
- **Token exchange:** swapping a user's sign-in token for one meant for a specific target, here the Agent Gateway, while keeping the same user.
- **Task owner:** the one assistant or agent that answers a given kind of request.

### Check yourself

1. Calder's clerks live in Teams and keep asking about blocked orders. What does the Joule and Microsoft 365 Copilot integration give them?
   - A. A copy of the SAP order data inside Microsoft 365 for Copilot to read
   - B. Joule inside Teams, with each answer marked as from Joule
   - C. A Copilot Studio agent that Calder no longer needs to test
   - D. One merged assistant that replaces Joule and Copilot alike

   Answer: B. SAP's lesson says the integration connects the two without merging them, starts in Teams and shows which assistant answered. SAP data stays in SAP and Joule reads it within the user's authorizations.

2. Both Joule and a Copilot Studio agent can answer "which orders are blocked?". What should the architect do?
   - A. Keep both, since more ways to ask always means more adoption
   - B. Let each user pick the assistant they like better for that task
   - C. Name one owner and route the other door to it
   - D. Ask the model vendor which assistant gives better answers

   Answer: C. Two owners give two answers and two places to fix problems. The ownership table names one owner per task.

3. Who should own "release the credit block on order 1000002"?
   - A. The Copilot Studio agent, because the clerk starts in Teams
   - B. Joule, with a confirmation step under the credit analyst's SAP role
   - C. Microsoft 365 Copilot, because the request arrives as a chat
   - D. Whichever assistant answers fastest at the time of the request

   Answer: B. It changes SAP data, so it goes through Joule's confirmation and SAP's authorization check. The entry point can be Teams; the owner is still Joule.

4. A business case for the integration counts only Microsoft 365 Copilot licences. What is missing?
   - A. Nothing, since Microsoft bills the whole integration
   - B. Azure model usage for every single answer that Joule gives
   - C. SAP's side: Joule licences and the AI Units SAP requires
   - D. A separate Teams licence for every SAP system Joule calls

   Answer: C. SAP's product page says AI Units are currently required for the feature, and Microsoft's post names Joule Base as a prerequisite. Both meters belong in the case.

5. The partner proposes one Microsoft Entra ID tenant for both test and production Joule. What do you answer?
   - A. Fine, since one tenant means fewer accounts to manage
   - B. No: Joule links one to one with an Entra tenant
   - C. Fine, as long as test users get different passwords there
   - D. No: production Joule must not use Entra ID at all

   Answer: B. SAP's expert setup guide says Joule has a one-to-one relationship with an Entra ID tenant and recommends a test tenant. Sharing one would mix the two environments.

6. A Copilot Studio agent will call a Joule agent through SAP's Agent Gateway. What is the key question for the vendor?
   - A. Which language model the Copilot Studio agent runs on
   - B. Whether the Joule agent can store all of Copilot's chat history
   - C. How many agents the gateway can list in its catalog
   - D. Whether SAP sees the real user, and if it is GA

   Answer: D. SAP's pattern keeps the named user so authorizations and audit work, and SAP's pages give mixed GA labels for the gateway. Both decide whether the design can go live.

## Deep layer

### Mental model

Treat every assistant as a **front door** and every system of record as a **room**. A front door may lead to many rooms, but each room has one keeper. Joule keeps SAP's rooms; Microsoft 365 Copilot keeps the Microsoft 365 rooms (mail, chats, files); a carrier's agent keeps the carrier's.

Three things then decide every design:

1. **Routing:** which keeper answers a request that arrives at a given door.
2. **Identity:** the person who knocked must still be the person when the keeper opens the room. SAP checks that person's authorizations, not the door's.
3. **Status:** each corridor between doors and rooms has its own GA label, and it changes month by month.

The deliverable is an ownership table plus the identity path for each corridor. This topic builds both, checks them against ten rules and traces six requests.

### How it works

SAP documents three corridors. [How Joule works](https://erpfde.com/topics/how-joule-works/) covers what happens inside Joule once a request arrives; this section covers how it arrives from, or leaves to, another assistant.

#### Corridor 1: Joule and Microsoft 365 Copilot

```mermaid
sequenceDiagram
  participant U as User in Teams
  participant M as Microsoft 365 Copilot
  participant E as Entra ID
  participant I as Cloud Identity Services
  participant J as Joule
  participant S as S/4HANA
  U->>M: SAP question
  M->>E: user signed in
  E->>I: federated sign-in
  M->>J: hand over to Joule
  J->>S: call as the mapped SAP user
  S-->>J: data within the user's roles
  J-->>U: answer marked as from Joule
```

- **What it is.** A product integration, not something you build. SAP's lesson lists a licensed Microsoft 365 Copilot environment, an activated Joule, identity alignment, and network and trust configuration as prerequisites. The integration is opt-in and enabled by default for neither product ([SAP Learning](https://learning.sap.com/courses/setting-up-joule-across-your-organizational-system-landscapes/setting-up-joule-with-microsoft-365-copilot)).
- **Both directions.** In Microsoft 365, Copilot reaches SAP processes and data through Joule. In SAP, Joule routes to Copilot when Microsoft 365 context such as email, Teams, SharePoint or OneDrive is relevant ([Microsoft Tech Community, 27 January 2026](https://techcommunity.microsoft.com/blog/sapapplications/sap--microsoft-365-a-unified-ai-experience-that-works-where-you-work/4480380)).
- **Setup outline.** An SAP product expert's guide describes the work: trust between Cloud Identity Services and Entra ID, admin consent for SAP's Teams bot app in Entra, a delegated `access_as_user` permission on the federation app, and a system of type *Microsoft 365 Copilot for SAP Joule* added to the Joule formation ([SAP Community](https://community.sap.com/t5/technology-blog-posts-by-sap/enable-microsoft-copilot-and-teams-to-pass-requests-to-joule/ba-p/14109137)). The guide also says Joule keeps a one-to-one relationship with an Entra ID tenant. SAP's lesson points to Discovery Center mission 4741 and a Help Portal page for the authoritative steps; this run could not open the Help Portal page.
- **Status.** SAP lists the bidirectional integration as general availability in its Q4 2025 release highlights ([SAP News, 14 January 2026](https://news.sap.com/2026/01/sap-business-ai-release-highlights-q4-2025/)).

#### Corridor 2: another platform's agent calls a Joule agent (inbound A2A)

```mermaid
sequenceDiagram
  participant C as Copilot Studio agent
  participant X as Custom connector
  participant I as Cloud Identity Services
  participant G as Agent Gateway
  participant A as Joule agent
  C->>X: SAP task, with the user's token
  X->>I: token exchange (jwt-bearer, resource = gateway)
  I-->>X: token for the gateway, same user
  X->>G: A2A call
  G->>G: check token, tenant, access list
  G->>A: route
  A-->>C: result, as the named user
```

- **The pattern.** SAP's Copilot reference architecture sends the call through a Power Platform custom connector that exchanges the token at Cloud Identity Services, then calls the Agent Gateway. It says Copilot Studio's native add-agent path can't perform that exchange ([SAP Architecture Center, 23 October 2026](https://architecture.learning.sap.com/docs/ref-arch/a2c0f1)). Gemini Enterprise uses a proxy agent on Google's agent runtime for the same job ([SAP Architecture Center, 27 October 2026](https://architecture.learning.sap.com/docs/ref-arch/c9a3f8)).
- **The token.** The exchange uses the `urn:ietf:params:oauth:grant-type:jwt-bearer` grant with a `resource` parameter. The new token's audience follows the resource; the subject and user type are kept. User types are `user`, `techUser` and `agentUser`. When an agent acts for a user, it gets the narrower of the user's and the agent's permissions. The token's authorization claim must hold `access@agent` for the target ([SAP Architecture Center, 13 October 2026](https://architecture.learning.sap.com/docs/ref-arch/f4a2c8)). The gateway audience on the Gemini page is `urn:sap:identity:application:provider:name:agent-gateway`.
- **Onboarding.** SAP's news post describes three SAP-managed formations: identity (integration with Cloud Identity Services), trust (*Agent Gateway for Third Party*) and authorization (*Agent Gateway Consumer*, which creates an access list). It adds that discovery doesn't grant permission, and that invoking an SAP agent needs a user token ([SAP Architecture Center news, 27 October 2026](https://architecture.learning.sap.com/news/2026/10/27/a2a-agent-gateway-interoperability)).
- **Status.** The news post announces October 2026 GA of inbound A2A. The Copilot and Gemini reference pages, updated days earlier, say the Agent Gateway is not yet GA. Record both and ask SAP.

[A2A for SAP agents](https://erpfde.com/topics/a2a-for-sap-agents/) teaches the protocol, and the [cross-platform agent project](https://erpfde.com/topics/project-cross-platform-agent/) builds a working stand-in of this corridor with a real token exchange. This topic doesn't repeat either.

#### Corridor 3: Joule calls an outside agent (outbound A2A)

Joule stays the orchestrator and calls the outside agent as an A2A client. A low-code agent from Joule Studio gets its scenario automatically; a pro-code agent needs a Joule scenario with a dialog function of action type `agent-request` pointing at the agent's A2A endpoint. Trust is an IAS App2App relationship between Joule and the agent's server. Joule expects a synchronous answer within 60 seconds; longer work uses push notifications to a Joule webhook. The page names A2A 0.3.0 and `message/send` ([SAP Architecture Center, 26 October 2026](https://architecture.learning.sap.com/docs/ref-arch/ae6821)). SAP's news post calls outbound A2A future scope for third-party agents, so treat this corridor as pilot work.

#### Who orchestrates

SAP's pages don't agree on one answer, and they don't need to: it depends on the door. The outbound page makes Joule "the central orchestrator" for users who start in Joule. The Gemini page makes Gemini Enterprise the orchestrator the user talks to, delegating SAP tasks to Joule agents. For an architect the rule is simpler than the debate: **the assistant at the user's door orchestrates; the keeper of the data answers.**

### Build it yourself

**Before you start:** finish [Set up your computer for this course](https://erpfde.com/topics/set-up-your-computer/) and [Set up for Unit 23](https://erpfde.com/topics/set-up-for-unit-23/). This lab needs no SAP or Microsoft account, no key and no network. Neither the Microsoft 365 Copilot integration nor the Agent Gateway has a free trial you could wire up here, so you review Calder's design as data.

You will write Calder's assistant design as two files (a partner's draft and a reviewed version), check them against ten rules, trace six tasks hop by hop, and produce the ownership table as a markdown file for a design document.

```mermaid
flowchart LR
  I[--init] --> DR[assistants_draft.json]
  I --> RV[assistants_reviewed.json]
  DR --> R[--review<br/>rules A01-A10]
  RV --> R
  DR --> T[--trace<br/>T01-T06]
  RV --> T
  T --> L[assistant_trace.jsonl]
  RV --> O[--owners]
  O --> MD[assistant_owners.md]
```

The script is a **course stand-in**. It reads a design and simulates the hops; it signs no tokens and calls no service. Rules A01 to A07 come from SAP's and Microsoft's pages cited above; A08 to A10 are course rules.

> **Note** **New words.** **JSON** is a text format for structured data. A **trace** is a step-by-step record of one request. A **token** is a signed note that says who the user is and which service it is for; its **audience** (`aud`) names that service and its **subject** (`sub`) names the user. An **exit code** is the number a program returns: 0 means fine, 2 here means the review found a FAIL.

#### What you need

- The course folder `orchestrate-course` with its `.venv`.
- No account, no key, no cost. The script uses only Python's built-in modules, so `requirements.txt` doesn't change.
- Time: about 30 minutes.

#### Step 1: Open your course folder and turn on the virtual environment

1. Open VS Code, then **File > Open Folder** and choose `orchestrate-course`.
2. Open a terminal with **Terminal > New Terminal**.
3. Turn on the virtual environment:
   - **Windows (PowerShell):**

     ```powershell
     .venv\Scripts\Activate.ps1
     ```

   - **macOS / Linux:**

     ```bash
     source .venv/bin/activate
     ```

4. Make the `unit23` folder if it doesn't exist yet:
   - **Windows (PowerShell):**

     ```powershell
     New-Item -ItemType Directory -Force unit23
     ```

   - **macOS / Linux:**

     ```bash
     mkdir -p unit23
     ```

You should see `(.venv)` at the start of the prompt.

#### Step 2: Create the script

1. In VS Code, create the file `unit23/assistant_routes.py`.
2. Paste the code below and save.

```python
"""Review who owns which task when Joule sits beside other assistants, and trace the requests.

Usage (run from the orchestrate-course folder):
  python unit23/assistant_routes.py --init                     write the draft and reviewed designs
  python unit23/assistant_routes.py --design FILE --review     check the design against rules A01-A10
  python unit23/assistant_routes.py --design FILE --trace      trace every task, hop by hop
  python unit23/assistant_routes.py --design FILE --trace --only T05
  python unit23/assistant_routes.py --design FILE --owners     write unit23/assistant_owners.md

Options:
  --force   let --init overwrite existing design files

Built-in modules only, no account, no network, no randomness. This is a course stand-in:
it checks a design written as data and simulates the hops; it calls no SAP or Microsoft
service. Calder Pumpworks is fictional; tenants, users, agents, rules A01-A10 and records
are course labels, not SAP or Microsoft values.
"""
import argparse
import copy
import json
import sys
from pathlib import Path

HERE = Path(__file__).resolve().parent
GATEWAY = "urn:sap:identity:application:provider:name:agent-gateway"

REVIEWED = {
    "as_of": "2026-11-28",
    "joule_instances": {
        "joule-prod": {"tier": "production", "identity_tenant": "calder-ias",
                       "entra_tenant": "calder-entra"},
        "joule-nonprod": {"tier": "non-production", "identity_tenant": "calder-ias-test",
                          "entra_tenant": "calder-entra-test"},
    },
    "people": {
        "cs.clerk@calder-pumpworks.example": {"sap_user": "00100265", "label": "customer service clerk",
                                              "sap_roles": ["JOULE_O2C_CLERK"]},
        "credit.analyst@calder-pumpworks.example": {"sap_user": "00100304", "label": "credit analyst",
                                                    "sap_roles": ["JOULE_O2C_CLERK", "JOULE_CREDIT_ANALYST"]},
        "logistics.planner@calder-pumpworks.example": {"sap_user": "00100322", "label": "transport planner",
                                                       "sap_roles": ["JOULE_O2C_CLERK"]},
    },
    "integrations": {
        "M365": {
            "kind": "joule-m365-copilot", "joule": "joule-prod", "entra_tenant": "calder-entra",
            "activated_by": "00100290", "stage": "production",
            "licences": {"joule_base": "confirmed", "microsoft_365": "confirmed",
                         "m365_copilot_for_copilot_skills": "confirmed", "ai_units": "open"},
            "status": [{"label": "GA", "source": "SAP Business AI release highlights Q4 2025",
                        "date": "2026-01-14"}],
            "audit": ["Joule conversation history", "Microsoft 365 audit log"],
        },
        "M365-T": {
            "kind": "joule-m365-copilot", "joule": "joule-nonprod", "entra_tenant": "calder-entra-test",
            "activated_by": "00100290", "stage": "test",
            "licences": {"joule_base": "confirmed", "microsoft_365": "confirmed",
                         "m365_copilot_for_copilot_skills": "confirmed", "ai_units": "open"},
            "status": [{"label": "GA", "source": "SAP Business AI release highlights Q4 2025",
                        "date": "2026-01-14"}],
            "audit": ["Joule conversation history", "Microsoft 365 audit log"],
        },
        "CS-A2A": {
            "kind": "inbound-a2a", "consumer": "copilot-cs-agent", "platform": "Copilot Studio",
            "activated_by": "00100292", "stage": "pilot",
            "connection": "custom connector with token exchange",
            "token": {"grant": "urn:ietf:params:oauth:grant-type:jwt-bearer", "resource": GATEWAY,
                      "aud": GATEWAY, "sub_preserved": True, "sap_user_type": "user"},
            "acl": ["AGT_ORDER_EXC"],
            "status": [{"label": "not GA", "source": "SAP Architecture Center, Microsoft Copilot "
                        "Integration with Joule Agents", "date": "2026-10-23"},
                       {"label": "GA (inbound A2A)", "source": "SAP Architecture Center news",
                        "date": "2026-10-27"}],
            "audit": ["Copilot Studio transcript", "SAP Cloud ALM (Agent Gateway)"],
        },
        "ETA-A2A": {
            "kind": "outbound-a2a", "agent": "carrier-eta-agent", "trust": "IAS App2App",
            "activated_by": "00100292", "stage": "pilot",
            "sync_seconds": 20, "push_notifications": True, "message_types": ["text"],
            "status": [{"label": "not GA", "source": "SAP Architecture Center, Integrating AI "
                        "Agents with Joule (Outbound A2A)", "date": "2026-10-26"}],
            "audit": ["Joule conversation history", "carrier-eta-agent log"],
        },
    },
    "tasks": [
        {"id": "T01", "ask": "Which of my orders are blocked?", "entry": "Teams",
         "person": "cs.clerk@calder-pumpworks.example", "owner": "joule", "via": "M365",
         "changes_sap": False},
        {"id": "T02", "ask": "Summarize Hallam's emails about the credit hold", "entry": "Joule",
         "person": "credit.analyst@calder-pumpworks.example", "owner": "m365-copilot", "via": "M365",
         "changes_sap": False},
        {"id": "T03", "ask": "Draft a reply to Hallam in Outlook", "entry": "Outlook",
         "person": "credit.analyst@calder-pumpworks.example", "owner": "m365-copilot", "via": None,
         "changes_sap": False},
        {"id": "T04", "ask": "Release the credit block on order 1000002", "entry": "Teams",
         "person": "credit.analyst@calder-pumpworks.example", "owner": "joule", "via": "M365",
         "changes_sap": True, "confirm": True, "sap_role": "JOULE_CREDIT_ANALYST"},
        {"id": "T05", "ask": "What is the next step on order 1000003?", "entry": "Copilot Studio agent",
         "person": "cs.clerk@calder-pumpworks.example", "owner": "AGT_ORDER_EXC", "via": "CS-A2A",
         "changes_sap": False},
        {"id": "T06", "ask": "When does the truck for delivery 80000011 arrive?", "entry": "Joule",
         "person": "logistics.planner@calder-pumpworks.example", "owner": "carrier-eta-agent",
         "via": "ETA-A2A", "changes_sap": False},
    ],
}


def make_draft():
    """The partner's first draft, with the mistakes a review should catch."""
    d = copy.deepcopy(REVIEWED)
    d["joule_instances"]["joule-nonprod"]["entra_tenant"] = "calder-entra"
    d["integrations"]["M365-T"]["entra_tenant"] = "calder-entra"
    d["integrations"]["M365"]["licences"]["m365_copilot_for_copilot_skills"] = "not planned"
    cs = d["integrations"]["CS-A2A"]
    cs["connection"] = "native add agent"
    cs["token"] = {"grant": "authorization_code", "resource": None, "aud": "copilot-cs-agent",
                   "sub_preserved": True, "sap_user_type": "user"}
    cs["acl"] = []
    cs["stage"] = "production"
    eta = d["integrations"]["ETA-A2A"]
    eta["sync_seconds"] = 90
    eta["push_notifications"] = False
    d["integrations"]["ETA-A2A"]["activated_by"] = None
    for t in d["tasks"]:
        if t["id"] == "T01":
            t["owner"] = ["joule", "copilot-cs-agent"]
        if t["id"] == "T04":
            t.update({"owner": "copilot-cs-agent", "via": "CS-A2A", "entry": "Copilot Studio agent",
                      "confirm": False, "sap_role": None})
    return d


def owners_of(task):
    o = task["owner"]
    return o if isinstance(o, list) else [o]


def review(d):
    """Return a list of (rule, verdict, object, message)."""
    out = []

    def add(rule, ok, obj, msg, warn=False):
        out.append((rule, "OK" if ok else ("WARN" if warn else "FAIL"), obj, msg))

    integ = d["integrations"]
    # A01 opt-in: every integration is activated on purpose and has an owner
    for iid, i in integ.items():
        add("A01", bool(i.get("activated_by")), iid,
            "activated by " + str(i.get("activated_by")) if i.get("activated_by")
            else "no named person activated it (the integration is opt-in)")
    # A02 one Microsoft Entra ID tenant per Joule environment
    seen = {}
    for name, j in d["joule_instances"].items():
        other = seen.get(j["entra_tenant"])
        add("A02", other is None, name,
            f"Entra tenant {j['entra_tenant']}" + (f" already used by {other}" if other else ""))
        seen.setdefault(j["entra_tenant"], name)
    for iid, i in integ.items():
        if i["kind"] == "joule-m365-copilot":
            want = d["joule_instances"][i["joule"]]["entra_tenant"]
            add("A02", i["entra_tenant"] == want, iid,
                f"{i['joule']} trusts {want}, integration uses {i['entra_tenant']}")
    # A03 licences
    copilot_skill_tasks = [t["id"] for t in d["tasks"]
                           if "m365-copilot" in owners_of(t) and t["entry"] == "Joule"]
    for iid, i in integ.items():
        if i["kind"] != "joule-m365-copilot":
            continue
        lic = i["licences"]
        base = lic["joule_base"] == "confirmed" and lic["microsoft_365"] == "confirmed"
        add("A03", base, iid, "Joule Base and Microsoft 365 confirmed" if base
            else "Joule Base or Microsoft 365 licence not confirmed")
        if copilot_skill_tasks:
            ok = lic["m365_copilot_for_copilot_skills"] == "confirmed"
            add("A03", ok, iid, f"Copilot skills used from Joule ({', '.join(copilot_skill_tasks)}): "
                f"Microsoft 365 Copilot licence {lic['m365_copilot_for_copilot_skills']}")
        add("A03", lic["ai_units"] == "confirmed", iid,
            f"AI Units {lic['ai_units']}: SAP's product page says they are currently required; "
            "confirm with SAP", warn=True)
    # A04 to A06 inbound A2A from another platform
    for iid, i in integ.items():
        if i["kind"] != "inbound-a2a":
            continue
        if i["platform"] == "Copilot Studio":
            add("A04", i["connection"] == "custom connector with token exchange", iid,
                f"connection: {i['connection']}")
        tok = i["token"]
        ok = (tok["grant"].endswith("jwt-bearer") and tok["resource"] == GATEWAY
              and tok["aud"] == GATEWAY)
        add("A05", ok, iid, f"grant {tok['grant']}, aud {tok['aud']}")
        add("A05", tok["sub_preserved"] and tok["sap_user_type"] == "user", iid,
            f"sub preserved {tok['sub_preserved']}, sap_user_type {tok['sap_user_type']}")
        targets = sorted({o for t in d["tasks"] if t.get("via") == iid for o in owners_of(t)
                          if o.startswith("AGT_")})
        missing = [a for a in targets if a not in i["acl"]]
        add("A06", not missing, iid, "access@agent for " + (", ".join(i["acl"]) or "nothing")
            + (f"; missing {', '.join(missing)}" if missing else ""))
    # A07 outbound A2A from Joule
    for iid, i in integ.items():
        if i["kind"] != "outbound-a2a":
            continue
        ok = i["sync_seconds"] <= 60 or i["push_notifications"]
        add("A07", ok, iid, f"answers in {i['sync_seconds']} s, push notifications "
            f"{'on' if i['push_notifications'] else 'off'} (Joule waits 60 s)")
        add("A07", i["message_types"] == ["text"], iid, f"message types {i['message_types']}")
    # A08 one owner per task; changes to SAP data stay with Joule, confirmed, under an SAP role
    for t in d["tasks"]:
        o = owners_of(t)
        add("A08", len(o) == 1, t["id"], f"owner {' and '.join(o)}")
        if t["changes_sap"]:
            ok = o == ["joule"] and t.get("confirm") and t.get("sap_role")
            add("A08", bool(ok), t["id"], f"changes SAP data: owner {o[0]}, confirm "
                f"{t.get('confirm')}, role {t.get('sap_role')}")
    # A09 production only on a path SAP labels GA; conflicting labels need SAP's answer
    for iid, i in integ.items():
        labels = {s["label"].split(" ")[0] for s in i["status"]}
        if len(labels) > 1:
            add("A09", False, iid, f"sources disagree ({'; '.join(s['label'] + ', ' + s['date'] for s in i['status'])}); "
                f"stage {i['stage']}: ask SAP", warn=i["stage"] != "production")
        else:
            ok = i["stage"] != "production" or labels == {"GA"}
            add("A09", ok, iid, f"{i['status'][0]['label']} ({i['status'][0]['date']}), stage {i['stage']}")
    # A10 an audit record on both sides
    for iid, i in integ.items():
        add("A10", len(i.get("audit", [])) >= 2, iid, "audit: " + ", ".join(i.get("audit", [])))
    return out


def trace(d, task):
    """Simulate one task hop by hop. Returns (hops, outcome)."""
    hops, results = [], {(r, o): v for r, v, o, _ in review(d)}
    person = d["people"][task["person"]]
    o = owners_of(task)

    def bad(rule, obj):
        return results.get((rule, obj)) == "FAIL"

    hops.append(f"{task['entry']}: {task['person']} asks \"{task['ask']}\"")
    if len(o) > 1:
        hops.append(f"two owners ({', '.join(o)}): the answer depends on which assistant the user opened")
        return hops, "AMBIGUOUS"
    owner, via = o[0], task.get("via")
    if via is None:
        hops.append(f"{owner} answers from Microsoft 365 data; SAP is not called")
        return hops, "ANSWERED by " + owner
    i = d["integrations"][via]
    if i["kind"] == "joule-m365-copilot":
        if bad("A02", via) or bad("A02", i["joule"]):
            hops.append(f"Entra tenant {i['entra_tenant']} is trusted by more than one Joule instance")
            hops.append("sign-in may land in the wrong Joule environment")
            return hops, "REFUSED at identity (A02)"
        hops.append(f"Microsoft Entra ID ({i['entra_tenant']}) signs the user in; "
                    f"SAP Cloud Identity Services ({d['joule_instances'][i['joule']]['identity_tenant']}) "
                    f"maps it to {person['sap_user']}")
        if owner == "joule":
            hops.append(f"{task['entry']} hands the request to Joule ({i['joule']}); the reply shows Joule answered")
            if task["changes_sap"]:
                if task["sap_role"] not in person["sap_roles"]:
                    return hops, f"REFUSED: {person['sap_user']} lacks {task['sap_role']}"
                hops.append(f"Joule shows the change and waits for confirmation; "
                            f"S/4HANA checks {person['sap_user']}'s authorizations")
                return hops, f"CHANGED in SAP after confirmation by {person['sap_user']}"
            hops.append(f"S/4HANA answers within {person['sap_user']}'s authorizations")
            return hops, "ANSWERED by joule"
        hops.append("Joule routes the Microsoft 365 part to Microsoft 365 Copilot")
        if i["licences"]["m365_copilot_for_copilot_skills"] != "confirmed":
            return hops, "REFUSED: no Microsoft 365 Copilot licence for Copilot skills (A03)"
        hops.append("Copilot reads email and Teams within the user's Microsoft 365 permissions")
        return hops, "ANSWERED by m365-copilot"
    if i["kind"] == "inbound-a2a":
        hops.append(f"{i['platform']} agent {i['consumer']} calls the Agent Gateway over A2A")
        tok = i["token"]
        hops.append(f"token: grant {tok['grant'].split(':')[-1]}, aud {tok['aud']}")
        if tok["aud"] != GATEWAY:
            return hops, "REFUSED at Agent Gateway: wrong audience (A05)"
        if owner.startswith("AGT_") and owner not in i["acl"]:
            return hops, f"REFUSED at Agent Gateway: no access@agent for {owner} (A06)"
        if not owner.startswith("AGT_"):
            hops.append(f"{owner} changes SAP through a write tool of its own; Joule never sees it")
            return hops, "UNSAFE: change outside Joule's confirmation (A08)"
        hops.append(f"gateway routes to {owner}, which acts as {person['sap_user']} "
                    "(the user's and the agent's permissions, whichever is narrower)")
        return hops, f"ANSWERED by {owner}"
    if i["kind"] == "outbound-a2a":
        hops.append(f"Joule calls {i['agent']} over A2A (IAS App2App trust), message/send with text")
        if i["sync_seconds"] > 60 and not i["push_notifications"]:
            hops.append(f"{i['agent']} needs {i['sync_seconds']} s; Joule stops waiting at 60 s")
            return hops, "TIMED OUT (A07)"
        hops.append(f"{i['agent']} answers in {i['sync_seconds']} s; the reply names it as the source")
        return hops, f"ANSWERED by {i['agent']}"
    return hops, "UNKNOWN PATH"


def owners_md(d):
    lines = [f"# Assistant ownership at Calder (as of {d['as_of']})", "",
             "| Task | Entry point | Owner | Path | Changes SAP | Trace result |",
             "| --- | --- | --- | --- | --- | --- |"]
    for t in d["tasks"]:
        _, outcome = trace(d, t)
        lines.append(f"| {t['id']} {t['ask']} | {t['entry']} | {' and '.join(owners_of(t))} | "
                     f"{t.get('via') or 'none'} | {'yes' if t['changes_sap'] else 'no'} | {outcome} |")
    lines += ["", "Course stand-in. Calder Pumpworks is fictional."]
    return "\n".join(lines) + "\n"


def main():
    p = argparse.ArgumentParser(description=__doc__.splitlines()[0])
    p.add_argument("--init", action="store_true")
    p.add_argument("--force", action="store_true")
    p.add_argument("--design")
    p.add_argument("--review", action="store_true")
    p.add_argument("--trace", action="store_true")
    p.add_argument("--only")
    p.add_argument("--owners", action="store_true")
    a = p.parse_args()

    if a.init:
        for name, data in (("assistants_draft.json", make_draft()),
                           ("assistants_reviewed.json", REVIEWED)):
            f = HERE / name
            if f.exists() and not a.force:
                print(f"SKIP {f.name} exists (use --force to overwrite)")
                continue
            f.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8")
            print(f"WROTE {f.name}")
        return 0
    if not a.design:
        p.error("give --init, or --design FILE with --review, --trace or --owners")
    path = Path(a.design)
    if not path.exists():
        print(f"MISSING {path}: run with --init first")
        return 1
    d = json.loads(path.read_text(encoding="utf-8"))
    code = 0
    if a.review:
        rows = review(d)
        for rule, verdict, obj, msg in rows:
            print(f"{verdict:<4}  {rule}  {obj:<14} {msg}")
        counts = {v: sum(1 for r in rows if r[1] == v) for v in ("OK", "WARN", "FAIL")}
        print(f"\n{counts['OK']} OK, {counts['WARN']} WARN, {counts['FAIL']} FAIL")
        code = 2 if counts["FAIL"] else 0
    if a.trace:
        log = HERE / "assistant_trace.jsonl"
        with log.open("w", encoding="utf-8") as fh:
            done = 0
            for t in d["tasks"]:
                if a.only and t["id"] != a.only:
                    continue
                hops, outcome = trace(d, t)
                print(f"\n{t['id']}  {outcome}")
                for n, h in enumerate(hops, 1):
                    print(f"  {n}. {h}")
                fh.write(json.dumps({"task": t["id"], "hops": hops, "outcome": outcome}) + "\n")
                done += 1
        print(f"\nwrote {done} trace(s) to {log.name}")
    if a.owners:
        f = HERE / "assistant_owners.md"
        f.write_text(owners_md(d), encoding="utf-8")
        print(f"WROTE {f.name}")
    return code


if __name__ == "__main__":
    sys.exit(main())
```

#### Step 3: Write the two designs

Run:

```bash
python unit23/assistant_routes.py --init
```

On macOS or Linux, use `python3` if `python` isn't found. You should see:

```text
WROTE assistants_draft.json
WROTE assistants_reviewed.json
```

Open `unit23/assistants_reviewed.json`. It has four parts: the two Joule instances with their Entra tenants, three people mapped to SAP users, four integrations (`M365` and `M365-T` for the Microsoft 365 Copilot integration in production and test, `CS-A2A` for Calder's Copilot Studio agent calling the order exceptions agent, `ETA-A2A` for Joule calling a carrier's agent) and six tasks with one owner each.

#### Step 4: Review the partner's draft

```bash
python unit23/assistant_routes.py --design unit23/assistants_draft.json --review
```

The last line and the failures should read:

```text
FAIL  A01  ETA-A2A        no named person activated it (the integration is opt-in)
FAIL  A02  joule-nonprod  Entra tenant calder-entra already used by joule-prod
FAIL  A03  M365           Copilot skills used from Joule (T02): Microsoft 365 Copilot licence not planned
FAIL  A04  CS-A2A         connection: native add agent
FAIL  A05  CS-A2A         grant authorization_code, aud copilot-cs-agent
FAIL  A06  CS-A2A         access@agent for nothing; missing AGT_ORDER_EXC
FAIL  A07  ETA-A2A        answers in 90 s, push notifications off (Joule waits 60 s)
FAIL  A08  T01            owner joule and copilot-cs-agent
FAIL  A08  T04            changes SAP data: owner copilot-cs-agent, confirm False, role None
FAIL  A09  CS-A2A         sources disagree (not GA, 2026-10-23; GA (inbound A2A), 2026-10-27); stage production: ask SAP

23 OK, 2 WARN, 10 FAIL
```

The exit code is 2. Each FAIL is a mistake a real partner draft can make: a test Joule sharing the production Entra tenant, the Copilot Studio agent added the native way so its token is meant for itself, no access list, two owners for one question, and a credit release handled outside Joule.

#### Step 5: Trace the draft and see what the failures do

```bash
python unit23/assistant_routes.py --design unit23/assistants_draft.json --trace
```

Look at four results:

```text
T01  AMBIGUOUS
T02  REFUSED: no Microsoft 365 Copilot licence for Copilot skills (A03)
T05  REFUSED at Agent Gateway: wrong audience (A05)
T06  TIMED OUT (A07)
```

T04, the credit release, is also refused at the gateway for the wrong audience. That hides a worse problem: fix the token and the draft's Copilot Studio agent would change SAP with its own tool, outside Joule's confirmation. The review caught it under A08 even though the trace stopped earlier. This is why you review the design, not only the traces.

#### Step 6: Review and trace the reviewed design

```bash
python unit23/assistant_routes.py --design unit23/assistants_reviewed.json --review
python unit23/assistant_routes.py --design unit23/assistants_reviewed.json --trace
```

The review ends:

```text
32 OK, 3 WARN, 0 FAIL
```

The three warnings are honest open questions, not mistakes: AI Units for the two Microsoft 365 integrations are not yet confirmed with SAP, and SAP's pages disagree about the Agent Gateway's GA status, so `CS-A2A` stays a pilot. Task T05 now traces like this:

```text
T05  ANSWERED by AGT_ORDER_EXC
  1. Copilot Studio agent: cs.clerk@calder-pumpworks.example asks "What is the next step on order 1000003?"
  2. Copilot Studio agent copilot-cs-agent calls the Agent Gateway over A2A
  3. token: grant jwt-bearer, aud urn:sap:identity:application:provider:name:agent-gateway
  4. gateway routes to AGT_ORDER_EXC, which acts as 00100265 (the user's and the agent's permissions, whichever is narrower)
```

> **Note** These counts and traces come from a made-up Calder design run through a course stand-in. They show the review method, not the behavior of SAP's or Microsoft's services.

#### Step 7: Write the ownership table

```bash
python unit23/assistant_routes.py --design unit23/assistants_reviewed.json --owners
```

You should see `WROTE assistant_owners.md`. Open it in VS Code and press **Ctrl+Shift+V** (Windows) or **Cmd+Shift+V** (macOS) to preview it. The table lists each task, its entry point, owner, path and trace result. It is the page to paste into a [solution design document](https://erpfde.com/topics/writing-a-solution-design-doc/).

#### Step 8: Save your work in Git

```bash
git add unit23/assistant_routes.py unit23/assistants_draft.json unit23/assistants_reviewed.json unit23/assistant_owners.md
git commit -m "Unit 23: assistant ownership and routes"
```

#### How the code works

| Part | What it does |
| --- | --- |
| `REVIEWED` | Calder's design: Joule instances and their Entra tenants, people, integrations, tasks |
| `make_draft()` | Copies the design and plants the partner's mistakes |
| `review()` | Checks rules A01 to A10 and returns OK, WARN or FAIL per object |
| `trace()` | Walks one task through its corridor and stops at the first hop that would fail |
| `owners_md()` | Writes the ownership table with each task's trace result |
| `main()` | Reads the options; exit code 2 when the review finds a FAIL |

#### If something goes wrong

| What you see | What it means | What to do |
| --- | --- | --- |
| `python` is not recognized / `command not found` | Python isn't on the path, or it's called `python3` | Use `python3`, or redo the Python step in the setup topic |
| `MISSING unit23/...json: run with --init first` | The design files don't exist yet | Run Step 3 |
| `SKIP assistants_draft.json exists` | `--init` won't overwrite your edits | Add `--force` to start over |
| `json.decoder.JSONDecodeError` | A comma or bracket is wrong after you edited a file | The message gives the line; compare with the blocks in the exercise |
| `KeyError: 'some.person@...'` | A task names a person not in `"people"` | Add the person or fix the spelling |
| A network or proxy error | Not possible here: the script makes no network calls | Check you are running this script, not another one |

### The SAP way

- **Joule and Microsoft 365 Copilot** (GA per SAP's Q4 2025 highlights). Activate it as an AI feature; SAP's product page says AI Units are currently required ([SAP](https://www.sap.com/products/artificial-intelligence/joule-joule-and-microsoft-365-copilot.html)). The page showed the offering as unavailable in the country it was read from, which may only reflect the reader's location; check availability for each country you operate in. SAP's lesson points to Discovery Center mission 4741 and the Help Portal for setup ([SAP Learning](https://learning.sap.com/courses/setting-up-joule-across-your-organizational-system-landscapes/setting-up-joule-with-microsoft-365-copilot)). Microsoft's post adds the SAP Joule app in Microsoft Marketplace ([Microsoft](https://techcommunity.microsoft.com/blog/sapapplications/sap--microsoft-365-a-unified-ai-experience-that-works-where-you-work/4480380)).
- **Agent Gateway for inbound A2A** (GA in October 2026 per SAP's news post; "not yet GA" on the reference pages updated 23 to 27 October). Registration goes through SAP for Me and three formations ([SAP Architecture Center news](https://architecture.learning.sap.com/news/2026/10/27/a2a-agent-gateway-interoperability)). The calling platform's side (custom connector, proxy agent) is the customer's to build and run.
- **Outbound A2A from Joule** (parts not yet GA). Joule Studio agents get their scenario automatically; pro-code agents need a manual scenario and dialog function ([SAP Architecture Center](https://architecture.learning.sap.com/docs/ref-arch/ae6821)).
- **Licensing.** At least three meters: SAP's (Joule, AI Units), Microsoft's (Microsoft 365, Microsoft 365 Copilot, Copilot Studio) and, for agent paths, whatever the calling platform charges. No unit prices are published on the pages read in this run.

### Build vs. SAP

| Situation | Use | Build anything? | Why |
| --- | --- | --- | --- |
| A Teams user asks something a Joule skill answers | Joule and Microsoft 365 Copilot | No | SAP owns the skill and the identity handling |
| A Joule user needs facts from email or Teams | The same integration, Joule to Copilot | No | Microsoft 365 owns those files |
| A Copilot Studio agent needs Calder's own SAP logic | Inbound A2A to a Joule agent | The connector and the agent | Logic stays in SAP; the user is kept |
| A narrow Teams agent over two or three SAP reads | Copilot Studio with an MCP server | The agent and the server | See [Copilot Studio and Azure with SAP](https://erpfde.com/topics/microsoft-copilot-studio-and-azure-with-sap/) |
| Joule users need an outside system's answer | Outbound A2A from Joule | The outside agent | Joule stays the door; the outside system owns the answer |
| Any change to SAP data | Joule, with confirmation | Only if no skill exists | SAP's authorization check and audit apply |

### Architecture view

**Where it sits.** Calder runs one production Joule (`joule-prod` in `calder-ai-prod`) and one non-production (`joule-nonprod`), as in the Unit 23 setup. Microsoft 365 sits beside them, signed in through Entra ID tenants `calder-entra` and `calder-entra-test`, each federated with the matching Cloud Identity Services tenant. The Copilot Studio agent and the carrier's agent are outside SAP; the Agent Gateway is SAP-managed.

```mermaid
flowchart LR
  subgraph MS[Microsoft 365]
    T[Teams / Copilot]
    CS[Copilot Studio agent]
  end
  E[Entra ID] --- I[Cloud Identity Services]
  T --> J[Joule]
  J --> T
  CS --> X[Custom connector] --> G[Agent Gateway] --> A[Joule agent]
  J --> C[Carrier agent]
  J --> S[S/4HANA CP10]
  A --> S
```

**Non-functional requirements.**

| Requirement | Typical target | What breaks if it's missed |
| --- | --- | --- |
| Identity | The named user reaches SAP at every hop | Authorizations and audit attach to a shared account |
| Environment separation | Own Entra tenant per Joule instance | Test users land in production, or the reverse |
| Latency | Outside agents answer within 60 s or use push | Joule stops waiting; the user sees no answer |
| Availability | Each corridor's status recorded with source and date | A pilot path ends up in production unnoticed |
| Cost | All meters on one page | The case undercounts AI Units or Copilot licences |

**Integration and identity.** People sign in once with Entra ID; Cloud Identity Services maps them to SAP users. In corridor 1 the product integration carries the user. In corridor 2 the caller exchanges the user's token for one whose audience is the Agent Gateway, and the gateway checks the access list. In corridor 3 Joule trusts the outside agent through IAS App2App, so the outside system decides what the user may see there. See [Joule authorizations and security](https://erpfde.com/topics/joule-authorizations-and-security/) for what SAP checks once the request is inside.

**The decision to record** (ADR form from the design-doc topic):

- *Context:* Calder's customer service works in Teams and has a Copilot Studio agent; SAP holds the orders; Joule is activated.
- *Options:* A, Joule in Microsoft 365 Copilot only. B, A plus inbound A2A from the Copilot Studio agent to the order exceptions agent. C, the Copilot Studio agent with its own write tools into SAP. D, everything in Joule, Copilot Studio retired.
- *Decision:* B. Every change to SAP data stays in Joule with confirmation; `CS-A2A` stays a pilot until SAP confirms GA under Calder's contract.
- *Consequences:* two configurations to own (Microsoft and SAP); an ownership table to keep current; three meters in the budget.

**What a design review will ask.**

1. Which assistant owns each task, and who updates the table when a skill is added?
2. Show the audit record for one request from Teams: which SAP user appears?
3. Is the test environment on its own Entra tenant?
4. Which corridors are GA under our contract, and who confirmed it, when?
5. Can any path change SAP data without Joule's confirmation?

### Production concerns

- **Security.** Insist on user tokens for every call that reaches SAP data; SAP's pattern requires one for invoking an SAP agent. Treat text from the other assistant as untrusted input: an email Copilot summarizes can carry instructions meant for an agent, as [prompt injection and tool poisoning](https://erpfde.com/topics/prompt-injection-and-tool-poisoning/) shows.
- **Authorizations.** Roles decide what a person can do from any door. Test the refusal cases from Teams as well as from Joule.
- **Evaluation.** Keep one test set per task, run from each entry point that reaches it, and compare answers. Two doors to one owner must give the same answer.
- **Cost.** Put all meters in one sheet and review monthly. A Copilot licence per user adds up fast if everyone gets Copilot skills inside Joule.
- **Operations.** Support needs to know which side to look at. The audit trail spans Microsoft 365, Joule and, for agent paths, the gateway; join them by time and user.
- **Clean core.** Nothing here changes S/4HANA. Calder-specific logic lives in a Joule agent, not in the other platform.

### Where AI fits

This whole topic is about AI assistants, so the question is narrower: what does a second assistant change? It adds one more consumer of SAP data and one more place a model can be misled. SAP delivers the routing and identity pieces; the customer owns the ownership table, the test sets and the decision of which corridors go live. Governing many agents across platforms is the subject of [AI Agent Hub and agent governance](https://erpfde.com/topics/ai-agent-hub-and-governance/) and a later Unit 23 topic on agent fleets.

### Pitfalls

- **Native add-agent in Copilot Studio.** SAP's page says it can't perform the token exchange; use a custom connector.
- **A shared Entra tenant for test and production Joule.** The one-to-one relationship breaks.
- **Two owners for one question.** Two answers, two support queues.
- **Writes from the other platform.** A Copilot Studio tool that changes SAP skips Joule's confirmation and may use a shared user.
- **Taking one GA label for all corridors.** The Microsoft 365 integration is GA; the agent paths carry mixed labels.
- **Slow outside agents.** Anything over 60 seconds needs push notifications, or Joule gives up.
- **Forgetting the meters.** AI Units on SAP's side, Copilot licences on Microsoft's.

### Exercise

Calder's aftermarket team works in Amazon Quick and wants to ask the order exceptions agent about Hallam's spare-part orders. SAP's reference architecture for inbound A2A lists Amazon Quick among the platforms that consume Joule agents ([SAP Architecture Center](https://architecture.learning.sap.com/docs/ref-arch/fe0d1d)). Add that corridor, and add a test that a clerk can't release a credit block from Teams.

1. Copy the reviewed design:
   - **Windows (PowerShell):** `Copy-Item unit23/assistants_reviewed.json unit23/assistants_exercise.json`
   - **macOS / Linux:** `cp unit23/assistants_reviewed.json unit23/assistants_exercise.json`
2. Open `unit23/assistants_exercise.json`. In `"people"`, type a comma after the last person's closing `}` and add:

   ```json
   "aftermarket.lead@calder-pumpworks.example": {"sap_user": "00100323", "label": "aftermarket lead",
     "sap_roles": ["JOULE_O2C_CLERK"]}
   ```

3. In `"integrations"`, type a comma after the closing `}` of `"ETA-A2A"` and add:

   ```json
   "AFT-A2A": {
     "kind": "inbound-a2a", "consumer": "quick-aftermarket-agent", "platform": "Amazon Quick",
     "activated_by": "00100292", "stage": "pilot", "connection": "proxy with token exchange",
     "token": {"grant": "urn:ietf:params:oauth:grant-type:jwt-bearer",
               "resource": "urn:sap:identity:application:provider:name:agent-gateway",
               "aud": "urn:sap:identity:application:provider:name:agent-gateway",
               "sub_preserved": true, "sap_user_type": "user"},
     "acl": ["AGT_ORDER_EXC"],
     "status": [{"label": "not GA", "source": "SAP Architecture Center, Integrating Joule Agents into Your Ecosystem", "date": "2026-10-26"}],
     "audit": ["Amazon Quick log", "SAP Cloud ALM (Agent Gateway)"]
   }
   ```

4. In `"tasks"`, type a comma after the last task's `}` and add:

   ```json
   {"id": "T07", "ask": "Which of Hallam's spare-part orders are blocked?", "entry": "Amazon Quick",
    "person": "aftermarket.lead@calder-pumpworks.example", "owner": "AGT_ORDER_EXC", "via": "AFT-A2A",
    "changes_sap": false},
   {"id": "T08", "ask": "Release the credit block on order 1000002", "entry": "Teams",
    "person": "cs.clerk@calder-pumpworks.example", "owner": "joule", "via": "M365",
    "changes_sap": true, "confirm": true, "sap_role": "JOULE_CREDIT_ANALYST"}
   ```

5. Review and trace:

   ```bash
   python unit23/assistant_routes.py --design unit23/assistants_exercise.json --review
   python unit23/assistant_routes.py --design unit23/assistants_exercise.json --trace --owners
   ```

6. Try one failure on purpose: remove `"AGT_ORDER_EXC"` from the `"acl"` of `AFT-A2A` (leave `[]`), run the review again, see the A06 FAIL, then put it back.

**Done when** the review ends with `41 OK, 3 WARN, 0 FAIL`, the trace shows `T07  ANSWERED by AGT_ORDER_EXC` and `T08  REFUSED: 00100265 lacks JOULE_CREDIT_ANALYST`, and `assistant_owners.md` lists eight tasks. Keep the file: the ownership table feeds the architect capstone's integration pack.

### Check yourself

1. In the reviewed design, who orchestrates task T05, and who answers it?
   - A. Joule orchestrates and the Copilot Studio agent answers it in Teams
   - B. Copilot Studio orchestrates; the order exceptions agent answers
   - C. The Agent Gateway orchestrates and Microsoft 365 Copilot answers
   - D. Microsoft 365 Copilot orchestrates and S/4HANA answers it directly

   Answer: B. The user's door is the Copilot Studio agent, so it orchestrates and hands the SAP part over A2A. The order exceptions agent keeps the SAP logic and answers as the named user.

2. Why does SAP's Copilot reference architecture use a custom connector instead of Copilot Studio's native add-agent path?
   - A. The native path doesn't support the A2A protocol in any form
   - B. The custom connector is faster for long-running agent tasks
   - C. The native path can't exchange the token for the gateway
   - D. The custom connector stores the user's SAP password for reuse

   Answer: C. The Agent Gateway accepts only a token meant for it. The connector runs the jwt-bearer exchange at Cloud Identity Services, keeping the same user, and the native path can't.

3. After the token exchange, which statement about the new token is right?
   - A. Its subject becomes the Copilot Studio agent's technical user
   - B. Its audience is the gateway; the user's subject is kept
   - C. It carries the user's SAP roles, copied over from Entra ID
   - D. It is valid for every SAP agent without an access list

   Answer: B. SAP's token exchange page says the audience follows the resource parameter while the subject and user type are preserved. The gateway still checks the access list for the target agent.

4. The order exceptions agent acts for clerk 00100265. Which permissions apply?
   - A. The agent's permissions, since the agent makes the call
   - B. The clerk's permissions, since the agent's do not count
   - C. The union of both, so the agent can finish more tasks
   - D. The intersection of the clerk's and the agent's permissions

   Answer: D. SAP's page says an agent acting in user context gets the intersection of user and agent permissions. Neither side can reach beyond what both allow.

5. In the draft, the carrier's agent needs 90 seconds and has push notifications off. What happens, and what fixes it?
   - A. The answer arrives late but whole; nothing to fix
   - B. The gateway retries until it answers; raise the retry count
   - C. Joule stops waiting at 60 s; turn on push notifications
   - D. Copilot answers instead; make Copilot the owner of the task

   Answer: C. SAP's outbound page says Joule expects a synchronous answer within 60 seconds and uses push notifications for longer tasks. Rule A07 checks exactly that.

6. A partner wants the Copilot Studio agent to release credit blocks with its own SAP tool, "to keep the clerk in Teams". What do you do?
   - A. Accept it if the tool uses a strong service account password only
   - B. Refuse: the release goes to Joule, with confirmation
   - C. Accept it, since the token exchange already preserves the user
   - D. Refuse, and move all of customer service off Teams instead

   Answer: B. Rule A08 keeps every change to SAP data in Joule's confirmation under an SAP role. The clerk can stay in Teams because the integration reaches Joule from there.

7. SAP's news post says inbound A2A is GA, and the reference page says the gateway is not yet GA. How should the design record it?
   - A. Trust the newer page and move the corridor to production
   - B. Trust the older page and drop the corridor from the design
   - C. Pick whichever label the calling platform's vendor prefers
   - D. Record both with dates, keep it a pilot, ask SAP

   Answer: D. Rule A09 fails a production stage when sources disagree and warns for a pilot. A written answer from SAP for your contract settles it.

8. Why does the review catch the draft's unsafe credit release when the trace doesn't show it?
   - A. The trace never runs tasks that change SAP data
   - B. The trace stops at the first failing hop, the wrong audience
   - C. The review uses a different copy of the design than the trace
   - D. The trace ignores tasks that start in Copilot Studio

   Answer: B. The trace stops when the gateway refuses the token, so it never reaches the write. The review checks every rule on the design, which is why you run both.

## Sources

- [Bi-directional integration between Joule and Microsoft 365 Copilot (sap.com product page)](https://www.sap.com/products/artificial-intelligence/joule-joule-and-microsoft-365-copilot.html): read 2026-11-28, no page date; Microsoft 365 users reach SAP tasks and data through Joule, SAP users reach Microsoft 365 information through Joule; "AI Units are currently required to use this AI offering"; the page showed the offering as not available in the reader's country or region, which may reflect where it was read from
- [Setting Up Joule with Microsoft 365 Copilot (SAP Learning lesson)](https://learning.sap.com/courses/setting-up-joule-across-your-organizational-system-landscapes/setting-up-joule-with-microsoft-365-copilot): read 2026-11-28, no date; connects the two without merging them; starts with Microsoft Teams; says whether Joule or Copilot answered; opt-in, enabled by default for neither; prerequisites: licensed Microsoft 365 Copilot environment, activated Joule, identity alignment, network and trust; points to Discovery Center mission 4741 and the Help Portal page
- [SAP and Microsoft 365: a unified AI experience that works where you work (Microsoft Tech Community, 27 January 2026, updated 9 February 2026)](https://techcommunity.microsoft.com/blog/sapapplications/sap--microsoft-365-a-unified-ai-experience-that-works-where-you-work/4480380): read 2026-11-28; co-authored by Microsoft and SAP; integration generally available; Joule in Teams, Word, PowerPoint, Excel and OneNote; Joule routes to Microsoft 365 Copilot when Microsoft 365 context is relevant; needs Joule Base and a Microsoft 365 licence, a Microsoft 365 Copilot licence only for Copilot skills within Joule; set up with the SAP Joule app from Microsoft Marketplace and a connection between SAP Cloud Identity Services and Microsoft Entra ID
- [SAP Business AI: Release Highlights Q4 2025 (SAP News, 14 January 2026)](https://news.sap.com/2026/01/sap-business-ai-release-highlights-q4-2025/): read 2026-11-28; bidirectional integration between Joule and Microsoft 365 Copilot listed as general availability
- [Enable Microsoft Copilot and Teams to pass requests to Joule (SAP Community, SAP product expert)](https://community.sap.com/t5/technology-blog-posts-by-sap/enable-microsoft-copilot-and-teams-to-pass-requests-to-joule/ba-p/14109137): read 2026-11-28, no date shown; prerequisite trust between SAP Cloud Identity Services and Microsoft Entra ID; Joule keeps a 1:1 relationship with an Entra ID tenant, so a test tenant is recommended; admin consent for SAP's Teams bot app, delegated permission access_as_user, a system of type Microsoft 365 Copilot for SAP Joule added to the Joule formation
- [Microsoft Copilot Integration with Joule Agents (SAP Architecture Center, updated 23 October 2026)](https://architecture.learning.sap.com/docs/ref-arch/a2c0f1): read 2026-11-28; Copilot Studio hands an SAP task through a Power Platform custom connector that exchanges the token at SAP Cloud Identity Services, then calls the Agent Gateway; the native add-agent path can't do the exchange; the user's subject is kept so actions are attributable; says the Agent Gateway is not yet GA
- [Third-Party A2A Integration & Token Exchange (SAP Architecture Center, updated 13 October 2026)](https://architecture.learning.sap.com/docs/ref-arch/f4a2c8): read 2026-11-28; jwt-bearer token exchange at Cloud Identity Services with a resource parameter; aud follows the resource, sub and user type are kept; user types user, techUser, agentUser; in user context the effective permission is the intersection of user and agent permissions; authZ claim needs access@agent; some propagation features still in preparation
- [Third-party agents can now interoperate with SAP Agents via the Agent Gateway (SAP Architecture Center news, 27 October 2026)](https://architecture.learning.sap.com/news/2026/10/27/a2a-agent-gateway-interoperability): read 2026-11-28; October 2026 general availability of inbound A2A; outbound A2A and outbound MCP future scope; invoking an SAP agent needs a user token; formations for identity, trust and authorization (an access list); discovery doesn't grant permission
- [Integrating AI Agents with Joule (Outbound A2A) (SAP Architecture Center, updated 26 October 2026)](https://architecture.learning.sap.com/docs/ref-arch/ae6821): read 2026-11-28; Joule as A2A client and central orchestrator; pro-code agents need a Joule scenario and a dialog function of action type agent-request; IAS App2App trust; synchronous answer within 60 seconds, push notifications for longer tasks; A2A 0.3.0; some components not yet GA
- [Gemini Enterprise Integration with Joule Agents (SAP Architecture Center, updated 27 October 2026)](https://architecture.learning.sap.com/docs/ref-arch/c9a3f8): read 2026-11-28; Gemini Enterprise is the orchestrator the user talks to; a proxy agent on Google's agent runtime signs the user in at Cloud Identity Services, exchanges the token for the agent gateway audience and relays A2A; says the Agent Gateway is not yet GA
