2026 Feb 17 10:53 PM - edited 2026 Feb 23 10:06 AM
Hi SAP Community,
I’m currently working through the excellent TechEd 2025 AI160 – “Build Your Own AI Agent-Based Solution with the Generative AI Hub” hands-on, specifically the JavaScript exercise.
My setup:
Productive SAP AI Core instance
Provisioned in SAP BTP Cockpit (extended plan)
Service keys fully configured
Running the tutorial using npm run tutorial in SAP Business Application Studio
The UI (port 3002), Agent (port 3001), and Mock Server (port 3000) all start successfully.
However, when triggering the agent from the UI, I get the following error in the browser:
Error: Failed to execute 'json' on 'Response':
Unexpected token '<', "<!DOCTYPE "... is not valid JSONIn the Network tab, I see:
GET /api/agent/trigger-agent → 404 / HTML responseI verified:
Vite proxy is configured to forward /api → http://localhost:3001
Agent server is running on port 3001
Endpoint /api/agent/trigger-agent exists in server.ts
x-thread-id header is being sent from the UI
Despite this, the response is sometimes HTML (404 / error page) instead of JSON, causing the parsing error.
Has anyone faced a similar issue with AI160 JavaScript exercises?
Is there anything specific to check regarding routing, proxying, or error handling when using productive AI Core instances?
Any guidance would be greatly appreciated. @ZhongpinWang, @deekshasinha
Thank you!
Request clarification before answering.
This question was resolved in GitHub issue #26.
The problem was a port conflict with SAP Business Application Studio (3000/3001). The application already occupies those ports, so the UI proxy hits an HTML error page instead of the agent route.
The latest version of the demo on GitHub improves the error messaging to make port conflicts more obvious.
To resolve the conflict, update the ports used by the mock server and agent server.
exercises/javascript/app/mock-server/src/server.ts file to set the mock server port to 3005 (or another free port).// exercises/javascript/app/mock-server/src/server.ts
-const port = process.env.PORT || 3001;
+const port = process.env.PORT || 3005;exercises/javascript/app/agent/src/setup.ts file to point the base URL to port 3005.// exercises/javascript/app/agent/src/setup.ts
export const BASE_URL_API_PURCHASEORDER_PROCESS_SRV =
`http://localhost:3005/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/`;exercises/javascript/app/agent/src/server.ts file to set the agent server port to 3006 (or another free port).// exercises/javascript/app/agent/src/server.ts
-const port = process.env.PORT || 3001;
+const port = process.env.PORT || 3006;exercises/javascript/app/ui/vite.config.ts file to point the UI proxy to port 3006.// exercises/javascript/app/ui/vite.config.ts
- target: 'http://localhost:3001',
+ target: 'http://localhost:3006',After these changes, the preview endpoint should route correctly, and the agent call should stop returning “HTML/404”.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@gregorw Curl works perfectly.. only SAP AI Core deployment doesn't support /chat/completionsendpoint.
curl -v -i -X POST \
"https://api.ai.prod.eu-central-1.aws.ml.hana.ondemand.com/v2/inference/deployments/d48a78b0811caa3b/chat/completions" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-H "AI-Resource-Group: <123>" \
-H "X-Tenant: e125da77-03b4-4f88-ad8c-d5055c2cfaea" \
-d '{"messages":[{"role":"user","content":"Hello!"}],"max_tokens":200}'When running the agent code (exercises/javascript/app/agent.ts or po-agents.js), I encounter this TypeScript compilation error:
Argument of type 'BaseMessage<MessageStructure<MessageToolSet>, MessageType>[]' is not assignable to parameter of type 'BaseLanguageModelInput'. Type 'BaseMessage<MessageStructure<MessageToolSet>, MessageType>[]' is not assignable to type 'BaseMessageLike[]'. [... full error in comment below]
Error location:
async function callModel({ messages }: typeof MessagesAnnotation.State) { const response = await modelWithTools.invoke(messages); // ❌ Error here return { messages: [response] }; }
Happy to provide more details or test fixes! Would love to see this resolved for productive SAP AI Core usage.
Thanks for the great work!
Manoj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 9 | |
| 7 | |
| 5 | |
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.