Problem/Motivation

There is no reason we can't collect the usage information in fiber mode, after the stream has fully consumed. We should have it.

Streaming still have to log it separately, since its yet to be consumed.

Steps to reproduce

1. Use xdebug to check if the usage is added to the final ChatOutput while running in a fiber thread

Proposed resolution

Add it to the Fiber version.

Remaining tasks

User interface changes

API changes

Data model changes

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

marcus_johansson created an issue. See original summary.

marcus_johansson’s picture

Status: Active » Needs review
marcus_johansson’s picture

Assigned: marcus_johansson » Unassigned
a.dmitriiev’s picture

Assigned: Unassigned » a.dmitriiev
a.dmitriiev’s picture

Status: Needs review » Reviewed & tested by the community

Tested with gpt-4.1 with the Fiber test from AI Core test from here tests/src/AiLlm/FiberTest.php.

The usage information is updated on every fiber call and it is "summed" up in the end.

a.dmitriiev’s picture

Assigned: a.dmitriiev » Unassigned
Status: Reviewed & tested by the community » Fixed

I have started a merge train

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.