refactor(routing): surface logger errors via slog.Warn
Replace silent `_ = r.Logger.LogDecision(...)` discards with an if-err check that emits slog.Warn on failure. A brain outage now produces a visible warn line instead of swallowing the telemetry error entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -46,7 +46,7 @@ func (r *Router) Run(ctx context.Context, in RunInput) (string, int64, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
out, ms, err := r.Complete(ctx, model, in.System, in.User)
|
out, ms, err := r.Complete(ctx, model, in.System, in.User)
|
||||||
_ = r.Logger.LogDecision(ctx, LogEntry{
|
if lerr := r.Logger.LogDecision(ctx, LogEntry{
|
||||||
SessionID: in.SessionID,
|
SessionID: in.SessionID,
|
||||||
Skill: in.Skill,
|
Skill: in.Skill,
|
||||||
Decision: decision.String(),
|
Decision: decision.String(),
|
||||||
@@ -54,12 +54,14 @@ func (r *Router) Run(ctx context.Context, in RunInput) (string, int64, error) {
|
|||||||
ProjectRoot: in.ProjectRoot,
|
ProjectRoot: in.ProjectRoot,
|
||||||
DurationMs: ms,
|
DurationMs: ms,
|
||||||
Failed: err != nil,
|
Failed: err != nil,
|
||||||
})
|
}); lerr != nil {
|
||||||
|
slog.Warn("router: log decision failed", "skill", in.Skill, "err", lerr)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil && decision == DecideLocal {
|
if err != nil && decision == DecideLocal {
|
||||||
slog.Warn("router: local failed, falling open to claude", "skill", in.Skill, "err", err)
|
slog.Warn("router: local failed, falling open to claude", "skill", in.Skill, "err", err)
|
||||||
out, ms, err = r.Complete(ctx, r.ClaudeModel, in.System, in.User)
|
out, ms, err = r.Complete(ctx, r.ClaudeModel, in.System, in.User)
|
||||||
_ = r.Logger.LogDecision(ctx, LogEntry{
|
if lerr := r.Logger.LogDecision(ctx, LogEntry{
|
||||||
SessionID: in.SessionID,
|
SessionID: in.SessionID,
|
||||||
Skill: in.Skill,
|
Skill: in.Skill,
|
||||||
Decision: "claude_fallback",
|
Decision: "claude_fallback",
|
||||||
@@ -67,7 +69,9 @@ func (r *Router) Run(ctx context.Context, in RunInput) (string, int64, error) {
|
|||||||
ProjectRoot: in.ProjectRoot,
|
ProjectRoot: in.ProjectRoot,
|
||||||
DurationMs: ms,
|
DurationMs: ms,
|
||||||
Failed: err != nil,
|
Failed: err != nil,
|
||||||
})
|
}); lerr != nil {
|
||||||
|
slog.Warn("router: log decision failed", "skill", in.Skill, "err", lerr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return out, ms, err
|
return out, ms, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user