mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-07-28 01:27:58 +00:00
cc7b4ca86b
Two bugs prevented the usage block from ever reaching the wire: 1. CallLLM read turnStateFromContext(ctx), but the raw ctx is not seeded with the turn state (only turnCtx is), so SetLastUsage/SetLastFinishReason were dropped — GetLastUsage() returned nil at finalize. Set them on the ts parameter directly, which is also what the streaming publisher reads. 2. The manager wraps the channel streamer in finalizeHookStreamer / splitMarkerStreamer, neither of which forwarded SetTurnUsage (it is not part of the bus.Streamer interface), so the type assertion in the publisher's Finalize failed silently. Mirror the existing SetModelName forwarding: add a turnUsageStreamer interface + setStreamerTurnUsage helper and SetTurnUsage methods on both wrappers (splitMarker also stores and re-applies usage to each freshly-begun part streamer). Adds regression tests asserting both wrappers forward SetTurnUsage. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>