---
title: "Stored conversations"
manual: "LLM Foundation"
version: "main"
permalink: "https://docs.typo3.org/permalink/netresearch/nr-llm:api-conversations@main"
source: "Api/Conversations.rst"
rendered: "2026-11-12T15:41:35+00:00"
---

# Stored conversations {#api-conversations}

Inject
`NetresearchNrLlmServiceFeatureConversationServiceInterface`
when each message should include the session's previous turns. It provides
`startSession()` and `send()`; persisted agent lifecycle operations belong
to [Persisted agent runtime](https://docs.typo3.org/permalink/netresearch/nr-llm:api-agent-runtime@main).

## Open and continue a session {#api-conversations-example}

**Conversation under an authenticated backend user's identity**

```php
use Netresearch\NrLlm\Domain\ValueObject\AiActorContext;

$actor = AiActorContext::fromBackendUser($backendUser);
$session = $conversations->startSession(
    $actor,
    'Article review',
    $configuration,
);
$reply = $conversations->send(
    $actor,
    $session->uuid,
    'Suggest a shorter introduction.',
);
```

Resolve `$configuration` through the guarded resolver shown in
[Step 5: Select a database configuration](https://docs.typo3.org/permalink/netresearch/nr-llm:integration-guide-step5@main). Construct the actor from authenticated server
state, never from user-supplied identity or permission fields.

## Method contracts {#api-conversations-contract}

\``startSession(AiActorContext $actor, string $title = '',
?LlmConfiguration $configuration = null): AiSession``
    Binds the session to a configuration. Omitting it resolves and binds the
    actor's usable default at creation time. Changing the installation's
    default later does not switch this session. Throws
    :php:`AccessDeniedException` for an unauthenticated actor or
:php:`ConfigurationNotFoundException\` when no usable default exists.

\``send(AiActorContext $actor, string $sessionUuid, string $userMessage,
?ChatOptions $options = null): CompletionResponse``
    Replays the stored history, sends the new message and stores the user and
    assistant turns. Throws :php:`InvalidArgumentException` for an unknown
    UUID and :php:`AccessDeniedException\` when the actor lacks access or the
bound configuration is no longer usable.

Knowing a session UUID grants no access. Every call checks the actor against
the session owner. CLI and queue callers use an explicitly scoped service
account rather than assuming user zero or inheriting a global backend user.

Conversations persist message content. Apply the session retention policy and
schedule deletion as described in [Data retention & purge](https://docs.typo3.org/permalink/netresearch/nr-llm:administration-data-retention@main).
