Summary
A single dead function-local import sits in the error-handling branch of Agent._chat_completion. It is never referenced within its enclosing method, so it can be removed with zero behaviour change. This is a minor dead-code tidy — not a feature cut.
Current behaviour
src/praisonai-agents/praisonaiagents/agent/chat_mixin.py:1998, inside _chat_completion (method spans lines 1747–2149):
# Use structured error classification for all error types (replaces legacy heuristic checks)
from ..llm.error_classifier import classify_llm_error
from ..llm.retry_utils import jittered_backoff # <-- never used in this method
classify_llm_error (line 1997) is used a few lines later. jittered_backoff, however, is never called anywhere between line 1998 and the method's end at line 2149.
The only live jittered_backoff call sites in the file are at lines 5628 and 5776, and both resolve to the agent-local variant imported at lines 5602/5748 (from .retry_utils import jittered_backoff), not the ..llm.retry_utils variant imported here.
Verification:
$ grep -n "jittered_backoff" agent/chat_mixin.py
1998: from ..llm.retry_utils import jittered_backoff # dead
5602: from .retry_utils import jittered_backoff
5628: delay = jittered_backoff(
5748: from .retry_utils import jittered_backoff, interruptible_sleep
5776: delay = jittered_backoff(
# No jittered_backoff( call exists between lines 1998 and 2149.
Why it matters
Maintenance / clarity. Being the only apparent consumer of llm/retry_utils.jittered_backoff inside chat_mixin, this dead line misleadingly implies the llm-variant backoff participates in the chat error path when it does not. The two backoff variants have deliberately different jitter semantics (symmetric ±50% vs positive-only additive), so a stray reference to the wrong one is an active source of confusion for anyone tracing retry timing. Runtime cost is negligible (one unused import executed on each error pass); the value here is removing a misleading dead reference.
Category
Dead code
Capability preserved
- All retry / backoff behaviour is unchanged — the active backoff at lines 5628 and 5776 (agent-local
jittered_backoff) is untouched.
- Structured error classification via
classify_llm_error is untouched.
- No public API, import path, or exception-handling behaviour changes.
Proposed approach
Remove the single dead import line only (remove dead code only).
Resolution sketch
# Before
from ..llm.error_classifier import classify_llm_error
from ..llm.retry_utils import jittered_backoff
# After (identical behaviour)
from ..llm.error_classifier import classify_llm_error
Severity
Low
Validation
- Traced the full enclosing method (
_chat_completion, lines 1747–2149): jittered_backoff is bound but never called in scope.
- Confirmed the live call sites (5628, 5776) use the agent-local
.retry_utils import, not this ..llm.retry_utils one.
- Confirmed
..llm.retry_utils.jittered_backoff remains a valid, tested symbol elsewhere; only this in-scope binding is dead.
- No API or behaviour loss; not intentional robustness (the import result is never read).
Keep unchanged
llm/retry_utils.jittered_backoff and agent/retry_utils.jittered_backoff both stay — their differing jitter semantics are intentional and must not be merged.
- The retry/backoff loops at lines 5602–5628 and 5748–5776.
classify_llm_error structured error classification and all surrounding error-handling logic.
Summary
A single dead function-local import sits in the error-handling branch of
Agent._chat_completion. It is never referenced within its enclosing method, so it can be removed with zero behaviour change. This is a minor dead-code tidy — not a feature cut.Current behaviour
src/praisonai-agents/praisonaiagents/agent/chat_mixin.py:1998, inside_chat_completion(method spans lines 1747–2149):classify_llm_error(line 1997) is used a few lines later.jittered_backoff, however, is never called anywhere between line 1998 and the method's end at line 2149.The only live
jittered_backoffcall sites in the file are at lines 5628 and 5776, and both resolve to the agent-local variant imported at lines 5602/5748 (from .retry_utils import jittered_backoff), not the..llm.retry_utilsvariant imported here.Verification:
Why it matters
Maintenance / clarity. Being the only apparent consumer of
llm/retry_utils.jittered_backoffinsidechat_mixin, this dead line misleadingly implies thellm-variant backoff participates in the chat error path when it does not. The two backoff variants have deliberately different jitter semantics (symmetric ±50% vs positive-only additive), so a stray reference to the wrong one is an active source of confusion for anyone tracing retry timing. Runtime cost is negligible (one unused import executed on each error pass); the value here is removing a misleading dead reference.Category
Dead code
Capability preserved
jittered_backoff) is untouched.classify_llm_erroris untouched.Proposed approach
Remove the single dead import line only (remove dead code only).
Resolution sketch
Severity
Low
Validation
_chat_completion, lines 1747–2149):jittered_backoffis bound but never called in scope..retry_utilsimport, not this..llm.retry_utilsone...llm.retry_utils.jittered_backoffremains a valid, tested symbol elsewhere; only this in-scope binding is dead.Keep unchanged
llm/retry_utils.jittered_backoffandagent/retry_utils.jittered_backoffboth stay — their differing jitter semantics are intentional and must not be merged.classify_llm_errorstructured error classification and all surrounding error-handling logic.