Why calling Glean /rest/api/v1/agents/runs/wait from PMD returns Status Code: 408
When an Extend presentation (.pmd) page invokes an external AI agent synchronously—such as calling a Glean Agent (POST /rest/api/v1/agents/runs/wait) from a pageActionButton onClick script using a deferred PMD endpoint ("deferred": true, "httpMethod": "POST")—the request often succeeds in Postman or on short prompts, but intermittently fails in the Extend UI with:
An endpoint error has occurred for 'generateGoalsApi' in 'home'
Status Code: 408
Request URL: https://api.glean.com/rest/api/v1/agents/runs/wait
Request Method: POSTThis happens because Glean’s /rest/api/v1/agents/runs/wait endpoint holds the HTTP connection open while the agent retrieves enterprise context and generates its multi-paragraph response (such as drafting annual performance goals from prior objectives). Workday Presentation Components enforce a strict 24-second timeout on any individual page endpoint (endPoints and outboundEndPoints), and treat HTTP 408 Request Timeout as a fatal endpoint error by default.
Adding "_bestEffort": true (with a leading underscore) does not prevent the timeout, and even the valid PMD attribute "bestEffort": true only suppresses the red page-level crash when a widget fails to render—it does not extend the HTTP socket timeout or return the delayed agent response to generateGoalsApi.invoke() inside onClick. Furthermore, hardcoding a static Authorization bearer string and authType: "noAuth" directly inside a .pmd file exposes credentials in app source code.
Moving Glean and Sana agent calls into Workday Orchestrate
Whether you are calling a Glean agent (POST /rest/api/v1/agents/runs/wait) or triggering a Sana agent via an external REST webhook, move the external HTTP call out of the .pmd page and into Workday Orchestrate, and store your credentials in the tenant rather than in the PMD:
| Integration Pattern | How It Connects to Workday | Recommended Use Case |
|---|---|---|
| Integration PatternCustom Agents in Sana / ASOR A2A | How It Connects to WorkdayCustom Agents built in App Builder and activated in Agent Management Hub (ASOR) are automatically available inside Sana and A2A-ready in Mode=Delegate |
Recommended Use CaseConversational interactions initiated by the user inside Sana or the Workday chat panel |
| Integration PatternTriggering an External Agent (Glean or Sana REST/Webhook) from an Extend Page | How It Connects to WorkdayExtend PMD page invokes a Workday Orchestration, which calls the external agent REST API using Send HTTP Request and credentials stored in Create External Client CredStore (or Orchestration Credentials / Integration Attributes) | Recommended Use CaseButton-driven Extend workflows (such as a Generate Smart Goals button on a goal-setting form) |
Step-by-step: Calling an external agent from Extend without 408 errors
1. Store external API credentials securely in the tenant
Never place a raw Bearer string or user identifier inside the headers array of a .pmd endpoint:
- If the external agent platform uses OAuth 2.0 Client Credentials or Authorization Code: Run the Create External Client CredStore task in your Workday tenant (secured to the Security Administration domain), configure the client ID, client secret, and token endpoint, and give it an External Reference ID (for example,
externalGoalAgentCred). In Orchestration Builder, open Settings > Credentials (Create Orchestration Credentials) and reference that CredStore entry. - If the external agent endpoint uses a static API bearer credential or webhook key: Store the credential in an App Attribute or Integration Attribute configured with masked display, or pass it through an orchestration credential header rather than hardcoding it in PMD JSON.
Also ensure your external agent platform’s firewall allowlists Workday’s regional outbound IP addresses (Reference: Workday Extend Basic Setup).
2. Configure the Send HTTP Request step in Orchestrate
In Orchestration Builder, create an orchestration that calls the external agent endpoint using the Send HTTP Request component:
- Set Method to
POSTand URL to your external agent endpoint (for example,https://api.glean.com/rest/api/v1/agents/runs/waitor your Sana agent webhook URL). - On the Auth tab, select the credential you configured in Settings > Credentials.
- On the Headers tab, add
Content-Typewith valueapplication/json(and any required acting-user header populated dynamically from the orchestration’s launch parameters). - On the Body tab, select Create Text Template with Content Type set to
application/json:handlebars { "agent_id": "{{lp.getSimpleData('agentId')}}", "input": { "Previous year objectives": "{{lp.getSimpleData('priorObjectives')}}", "Goal Category I": "{{lp.getSimpleData('goalCategory')}}", "Answer to prompt": "{{lp.getSimpleData('promptAnswer')}}" } } - On the Settings tab of the Send HTTP Request step, increase Overall Timeout, Connect Timeout, and Response Timeout so the HTTP client waits for the external agent run to finish without cutting off at 10–24 seconds.
3. Choose Synchronous vs. Asynchronous launch based on agent latency
- If the external agent consistently finishes in under 20 seconds: You can expose the orchestration as a Synchronous Orchestration and extract the assistant message in Orchestrate before returning it to the PMD page:
javascript data.CallExternalAgent.response .asJSON() .stringAtJsonPath("$.messages[1].content[0].text") - If the external agent frequently takes longer than 20–25 seconds: Remember that a Synchronous Orchestration triggered from a PMD page still hits the 25-second presentation limit. In that case, use either the external agent’s non-blocking start-run + polling endpoints, or trigger an Asynchronous Orchestration that writes the generated goals into an Extend Business Object (
goalSuggestionDraft) and lets the user click Refresh Suggestions on the PMD page once the run completes.
Verifying the external agent call in your tenant
Trigger the Generate Smart Goals action from your Extend page in the tenant and open Orchestration Activity on the Developer Site. Select the orchestration run and inspect the Send HTTP Request step in the Summary Report: confirm that the step returns HTTP 200, that the response body contains the messages array with role: "GLEAN_AI" (or your Sana agent output), and that no 408 Request Timeout occurs on the PMD page.