Problem/Motivation

Streamed chat responses are not being recorded in the AI log.
The doIterate() method does not pass raw response data to createStreamedChatMessage(), resulting in empty output in logs.
Additionally, the iterator is missing: token usage tracking, finish reason tracking & tool calls passthrough

Steps to reproduce

1. Configure Mistral API key at /admin/config/ai/providers/mistral
2. Enable ai_logging module with response logging enabled
3. Go to /admin/config/ai/explorers → Chat
4. Enable streaming option
5. Send a message
6. Check /admin/config/ai/logging/collection
7. Result: Log entry has empty or minimal response data

Proposed resolution

Update MistralChatMessageIterator::doIterate() to properly pass all parameters to createStreamedChatMessage().
See also how OpenAiChatMessageIterator handles streaming.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

petar_basic created an issue. See original summary.

petar_basic’s picture

Status: Needs work » Needs review

The iterator was missing raw response data, tool calls, token usage tracking, and finish reason - now aligned with how OpenAI provider handles it.
Also extracted the responseToArray() into a trait to avoid duplication between the provider and iterator classes.

petar_basic’s picture

Assigned: petar_basic » Unassigned
fago’s picture

Title: Streamed chat responses (still) not logged & missing token usage/finish reason tracking » Streamed chat responses miss tool calls und usage tracking
Assigned: Unassigned » fago

Thx, code looks good. I'm giving this a test-run!

fago’s picture

Assigned: fago » Unassigned

I had to create https://www.drupal.org/project/ai/issues/3571925#comment-16457948 for being able to test it. But now, it works and see items logged correctly!

fago’s picture

Status: Needs review » Reviewed & tested by the community

Moved it into the merge train.

  • fago committed 08474d15 on 1.1.x authored by petar_basic
    fix: #3571505: Streamed chat responses miss tool calls und usage...
fago’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.