feat(agent): add FreeRide provenance marker 🦞 to responses
This commit is contained in:
parent
7cd0ac1047
commit
94a2756b8e
2 changed files with 23 additions and 1 deletions
|
|
@ -1776,10 +1776,14 @@ func (al *AgentLoop) runAgentLoop(
|
|||
}
|
||||
|
||||
if opts.SendResponse && result.finalContent != "" {
|
||||
finalContent := result.finalContent
|
||||
if usedFallback, fallbackModel := ts.GetFallbackInfo(); usedFallback {
|
||||
finalContent += fmt.Sprintf("\n\n🦞 _(FreeRide: %s)_", fallbackModel)
|
||||
}
|
||||
al.bus.PublishOutbound(ctx, bus.OutboundMessage{
|
||||
Channel: opts.Channel,
|
||||
ChatID: opts.ChatID,
|
||||
Content: result.finalContent,
|
||||
Content: finalContent,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -2221,6 +2225,7 @@ turnLoop:
|
|||
fbResult.Provider, fbResult.Model, len(fbResult.Attempts)+1),
|
||||
map[string]any{"agent_id": ts.agent.ID, "iteration": iteration},
|
||||
)
|
||||
ts.SetFallbackInfo(true, fbResult.Model)
|
||||
}
|
||||
return fbResult.Response, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,8 @@ type turnState struct {
|
|||
tokenBudget *atomic.Int64 // Shared token budget counter
|
||||
lastFinishReason string // Last LLM finish_reason
|
||||
lastUsage *providers.UsageInfo // Last LLM usage info
|
||||
usedFallback bool // Whether a fallback/FreeRide model was used
|
||||
fallbackModel string // The name of the fallback model used
|
||||
|
||||
// Back-reference to the owning AgentLoop (set for SubTurns only, used for hard abort cascade)
|
||||
al *AgentLoop
|
||||
|
|
@ -478,6 +480,21 @@ func (ts *turnState) SetLastUsage(usage *providers.UsageInfo) {
|
|||
ts.lastUsage = usage
|
||||
}
|
||||
|
||||
// SetFallbackInfo sets fallback model info
|
||||
func (ts *turnState) SetFallbackInfo(used bool, model string) {
|
||||
ts.mu.Lock()
|
||||
defer ts.mu.Unlock()
|
||||
ts.usedFallback = used
|
||||
ts.fallbackModel = model
|
||||
}
|
||||
|
||||
// GetFallbackInfo returns fallback model info
|
||||
func (ts *turnState) GetFallbackInfo() (bool, string) {
|
||||
ts.mu.RLock()
|
||||
defer ts.mu.RUnlock()
|
||||
return ts.usedFallback, ts.fallbackModel
|
||||
}
|
||||
|
||||
// Context helper functions for SubTurn
|
||||
|
||||
type turnStateKeyType struct{}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue