fix(agent): raise AgentLLMError after retry exhaustion - #1943
Open
tripathiji1312 wants to merge 1 commit into
Open
fix(agent): raise AgentLLMError after retry exhaustion#1943tripathiji1312 wants to merge 1 commit into
tripathiji1312 wants to merge 1 commit into
Conversation
Agent.run previously swallowed LLM failures: the retry loop caught bare Exception and, after exhausting retries, returned the raw conversation transcript as if it were the answer. It now: - catches only litellm errors (BadRequestError, InternalServerError, AuthenticationError) so non-retryable errors propagate immediately, and - raises AgentLLMError (matching the documented contract) instead of returning the transcript, with the attempt count in the message. Split from kyegomez#1931: this PR is the behavior change only (2 hunks in agent.py, 1 telemetry file, 1 new test file). The requires_llm markers (kyegomez#1940) should land first so the live-LLM tests stay green; the error re-export (kyegomez#1939) is independent.
|
Hello there, thank you for opening an PR ! 🙏🏻 The team was notified and they will get back to you asap. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Agent.runpreviously swallowed LLM failures: the retry loop caught bareException, and after exhausting retries it returned the raw conversation transcript as if it were the answer. This PR makes it honest — matching the docstring contract.Changes
swarms/structs/agent.py— 2 hunks, 15 lines:_runretry loop: remove bareExceptionfrom the except tuple (onlyBadRequestError,InternalServerError,AuthenticationErrorare retried; other errors propagate immediately).if not success:block:raise AgentLLMError(...)with the attempt count instead oflogger.error(...)+break(the transcript-return lets callers act on garbage output with no signal the model never responded).run()fallback path: same except-tuple tightening (removeException).tests/telemetry/test_telemetry_multi_agent_core.py— theFakeLLMnow raises a realisticBadRequestError, and the per-architecture error tests assert the new honest behavior (AgentLLMErrorpropagation +Agent.llm_errorspan, instead of the old always-swallowedcompleted/OK).tests/structs/test_agent_run_errors.py— new:TestFailureHonesty(3 tests: raise after retries, message reports attempt count, hierarchy).Why this PR is small
Split from #1931 (21 files → 3 PRs) per maintainer feedback. The other two are:
fix(agent): re-export error classes from swarms.structs.agent(1 file, fixes 4 failing marketplace tests) — independent.test: skip live-LLM tests when no API key is set(18 files, 451 insertions, no behavior change) — should merge before this one so the ~90 live-LLM tests stay green (they callagent.run()without keys and would all fail once this raise lands).Verification
tests/telemetry/.tests/structs/+tests/telemetry/vs baseline: zero new failures outside the expected skips (markers are in test: skip live-LLM tests when no API key is set #1940 — this PR intentionally does NOT include them so the diff stays reviewable).