permissionPolicy.type to always_ask. Without tools, you can still start with text conversation and refresh recovery.
1. Create a session and submit work
Use curl, jq and a user login token to test the same interaction as the local console. A business backend can instead use the authorized Application key from the integration guide. Substitute actual resource IDs; omitenvironmentId from the creation request if the Agent has a default Environment. Local Gateway defaults to port 18080.
SESSION_ID so the chat page route can identify this conversation, and save TURN_ID to identify the submitted task. Create a new Session only when the user starts a new conversation. On refresh, read the existing records rather than creating a conversation or sending the question again.
The two example idempotency keys identify Session creation and task submission separately. After a network timeout, retry the same operation with its original key and unchanged request body. Generate a new key when the user actually starts another conversation or submits the next question.
2. Restore content before subscribing
turn_id and its turn.completed event or queried Turn state to determine success. See SSE and event replay for deduplication, reconnects, and backend notifications.
3. Connect your page
The console Session Execution tab already connects these interactions, usingagentscope-service/frontend/src/components/SessionExecution.tsx. Submit a task, inspect tool calls, and answer pending actions there to understand a complete interaction before adding the same capabilities to your own page.
The following connection code can live under Console src/. It uses api/agentSessions.ts to read snapshots and events, then api/agentSessionView.ts to apply events to page state. These files are console client implementations. When moving them into another application, also adapt the api/http.ts authentication dependency and session types to your Gateway and login flow.
mountConversation(sessionId, render, showError) to restore content and subscribe to further events. Before leaving the page or switching conversations, call the returned cleanup function to stop receiving the old Session’s events. The render callback updates existing cards by message and tool call ID so each response or tool call continues in the same place.
The client reconnects brief network interruptions from the last successfully applied cursor. A refresh loads a new snapshot. Storing only a cursor in localStorage without the corresponding view loses the prefix. Authentication and other non-recoverable request errors reach showError for the page to handle.
Refresh can occur while tool arguments are still being generated. The reducer uses snapshot’s active_tool_call_id to attach later fragments without a call ID. A task can produce multiple assistant items and tool calls; do not append every delta to the last message.
4. Wire user actions to commands
The following table connects chat page actions to the Session API. Paths are relative toSESSION_URL. Use Session, Turn, and request IDs returned by the service to identify existing work; Service manages the execution process.
Provide a stable
Idempotency-Key when creating a Turn, changing requirements, adding context, or answering a pending action. The example below submits confirmation after the user inspects the tool request and chooses “Allow”. REQUEST_ID must come from the pending card’s request_id; a tool call ID cannot replace it:
output and is_error inside payload. An identity-bound confirmation requires the designated person’s authorized user identity. See Answer a required action for locating the action and following command receipts. These answers advance the existing task; its Turn result still determines completion.
5. Exercise the flow with real tools
To verify the full interaction, bind at least two usable tool operations and require user confirmation for one. Submit a task matching their capabilities, such as “Read two documents, check each and write a summary”. While the Agent calls tools and prepares its result, try the page operations below and check that the application restores earlier content and follows subsequent execution.
Page recovery above only restores the display of existing work. Restoring an earlier checkpoint changes Agent context and is followed by a new Turn. To continue the original interrupted task, check recovery conditions before using
resume. See Sessions, tasks, and budgets for these execution operations.
When the page also needs file upload or result download, add those capabilities with Files and artifacts. To notify your business backend after users leave the page, configure Webhooks in SSE and event replay.