OpalConversationDriver

Orchestrates LLM conversations with streaming, block parsing, and TaskPlan submission.

Inherits QObject
Group libopal

Declared in src/libs/libopal/opal/OpalConversationDriver.hpp.

Detailed description

Manages the lifecycle of a single OPAL conversation: builds the system prompt from the task registry, sends user messages through a streaming LLMClient, parses structured content blocks from the response, and submits any embedded TaskPlans for execution.

The turns run on a Session facet

The chat is a session of the session store (trove-parts §TPN-9), and its turns run on a Session facet of this chat (OpalChatSessions::createTurnSession()). Claude Code runs on the stream transport: one live claude process per chat session, in the assistant profile (§TPN-4, §TPN-9b). OnlineAPIClient gives a Session facet of its own. Every other client gives a ClientSessionFacet, which runs each turn as one completion with the history. So the chat has one code path for every provider.

A turn that fails after the session reported a limit shows the used quota and when it resets. A turn that fails after the session asked for a sign-in shows how to sign in to Claude Code again.

The history of the chat holds what the model got and gets: the user's messages, the "[System: …]" notes of the app, and the replies. A turn sends what the history gained since the last turn, as one prompt with its images: the notes first, in order, then the user's words. The session keeps the conversation; the chat never sends it twice.

The session gives the transport figures of a turn and the activity of the provider, which the bubble and the activity line show. When the chat opens a stored session, the session adopts the stored provider session and the stored history (ISession::adoptSession()). A provider that lost its session gets the turn again on a new one, and a system event records the change (TPX-44). The chat holds the lease of its session while the session is open in it (§TPN-6).

See also OpalChatOverlay, LLMClient, LLMSession, ClientSessionFacet.

In this section