Conversations and recovery

This page provides the copyable Markdown source for the conversations-and-recovery.md reference used by the Codex skill.

Copyable Markdown source

Copy the following block into references/conversations-and-recovery.md.

# Conversations and recovery

Read when the requested agent waits for user input, spans multiple turns, or needs recovery after interruption. First confirm the target release supports the required nodes, durable execution, and public package overloads. These design checks do not establish feature availability. If the matching released documentation or target package signature is unavailable, state that executable SQL remains unverified and ask for the release or package declaration needed to finish it.

## Choose the interaction

- A one-call task can use the ordinary immediate or stored execution interface. Do not add persistence or a conversational loop without a requirement.
- A multi-turn task needs application-managed conversation identity and an explicit waiting/continuation contract. Distinguish an initial invocation from continuing an existing conversation.
- Recovering a failed durable execution and supplying a message to a waiting conversation are different operations even if the supported API exposes them through overloads of the same routine.

Where supported, `InputMessageNode` is the user-input boundary and `OutputMessageNode` emits an assistant message. Verify exact spelling, template fields, and port contracts before generating JSON. An input node may wait without a prompt template; do not invent a synthetic assistant prompt. A rendered input prompt should appear once before the wait. An output message should appear once and in order.

## Caller lifecycle

For a release that documents this interface:

1. Start the durable execution and retain its returned conversation identifier under the correct application user.
2. Read the returned status. `WAITING_FOR_INPUT` is a pause, not a completed business result or an execution failure. Handle `COMPLETED` and `FAILED` separately according to the supported API.
3. Continue a waiting conversation with the same identifier and the next user message. Do not start a new execution for each turn or resend the whole transcript as a new message unless the API requires it.
4. Treat `new_messages` as the messages returned for the current invocation boundary, not full history. Use the supported history API for cumulative ordered history. Do not assume a message-index field exists.
5. Preserve long message content using the documented CLOB interface. Avoid accidental 32 KB truncation in bind variables, rendering, or logging.

Before writing calls involving `EXECUTE_AGENT`, `RESUME_AGENT`, or `GET_CONVERSATION_HISTORY`, verify their exact overloads, parameter modes/types, return values, and availability. The names alone do not establish a callable signature. Do not infer a durable overload for `EXECUTE_IMMEDIATE` from an ordinary immediate-execution example.

## Replay and side effects

Durable state and external effects are different guarantees. A tool may perform its external effect before its output is durably recorded; a retry can then repeat the call. Do not promise exactly-once payments, emails, or writes because an execution is resumable. Establish application/tool idempotency, deduplication keys, and authorization for operations that need them.

Test failure recovery separately from ordinary multi-turn continuation. Check that completed work and previously returned messages are preserved. For repeated or nested component visits, verify recovery of the correct visit rather than identifying it solely by a static component ID. Avoid imposing internal checkpoint layout on user code.

Do not put an input wait inside parallel work without confirming that placement is supported, including nested subflows. Prefer placing the user-input boundary before parallel work when it satisfies the request. Do not propose hidden database parameters to bypass a placement restriction. Do not assume output-message nodes share input-node restrictions.

## Validation evidence

A useful test captures initial status, conversation ID, each continuation status, current-call messages, cumulative history, and final output. Test at least two turns when history matters. Assert message ordering and lack of duplicate consumption or output. Add a failure/retry case when recovery is a requirement.

Keep database acceptance, runtime behavior, and failure-injection results separate. A test plan's expected result or completion label is not a live result for the user's deployment.

## Documentation entry point

- [Execute an Agent](https://docs.oracle.com/en/database/oracle/oracle-database/26/odbae/create-and-manage-agents/execute-an-agent.html)

Use the matching release's current conversation/resumability documentation before presenting an executable example; the ordinary execution page may not document those features.