feat(chat): implement orphan alias detection and logging in chat completion and streaming
Add functionality to detect unresolvable resource aliases emitted by the model during chat completion and streaming. Introduce logging for these orphan aliases to aid in debugging and improve the handling of resource references. Update the stream processing to ensure held aliases are flushed upon cancellation, preventing data loss. Include tests to verify the correct reporting of orphan aliases.
This commit is contained in:
@@ -106,6 +106,10 @@ func (e *AgentEngine) streamLLMToEventBus(
|
||||
// accumulated call in the final chunk. Decode once more after assembly so
|
||||
// aliases split across provider chunks cannot leak into tool execution.
|
||||
e.resourceRefs.DecodeToolCalls(result.ToolCalls)
|
||||
if orphans := e.resourceRefs.OrphanAliases(result.Content); len(orphans) > 0 {
|
||||
logger.Warnf(ctx, "[Agent][Stream] Model emitted %d unresolvable resource alias(es): %v",
|
||||
len(orphans), orphans)
|
||||
}
|
||||
|
||||
// Stream diagnostic summary: helps identify non-streaming patterns
|
||||
streamDuration := time.Duration(0)
|
||||
|
||||
Reference in New Issue
Block a user