feat(loop): agent loop(8 轮 + checkpoint + 流式 + 记忆注入/提取 + trace + 工具超时回喂)
This commit is contained in:
1 parent
01a4e29f84
commit
71697ca4f8
12 files changed
+1292
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package loop
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/trace"
|
||||
)
|
||||
|
||||
// span starts a named span of the given kind when a Tracer is configured, else
|
||||
// returns a nil no-op span. The returned context carries the span as the current
|
||||
// one so nested spans chain as children.
|
||||
func (l *Loop) span(ctx context.Context, name string, kind trace.SpanKind) (context.Context, *trace.Span) {
|
||||
if l.tracer == nil {
|
||||
return ctx, nil
|
||||
}
|
||||
return l.tracer.StartSpan(ctx, name, kind)
|
||||
}
|
||||
|
||||
// finishSpan closes a span with the given status, ignoring a nil span.
|
||||
func (l *Loop) finishSpan(sp *trace.Span, status trace.SpanStatus) {
|
||||
if sp == nil {
|
||||
return
|
||||
}
|
||||
sp.Finish(status)
|
||||
}
|
||||
|
||||
// spanProp attaches a structured property to a span, ignoring a nil span and any
|
||||
// mutation-after-close error.
|
||||
func (l *Loop) spanProp(sp *trace.Span, key string, value any) {
|
||||
if sp == nil {
|
||||
return
|
||||
}
|
||||
_ = sp.SetProp(key, value)
|
||||
}
|
||||
Reference in new issue
Block a user