diff --git a/lib/gpt_agent.ex b/lib/gpt_agent.ex index c92f7cb..f9dd929 100644 --- a/lib/gpt_agent.ex +++ b/lib/gpt_agent.ex @@ -487,6 +487,7 @@ defmodule GptAgent do state |> Map.update!(:rate_limit_retry_attempt, &(&1 + 1)) + |> Map.put(:running?, false) |> publish_event( RateLimited.new!( run_id: id, @@ -520,6 +521,7 @@ defmodule GptAgent do log("Run ID #{inspect(id)} failed due to OpenAI account quota reached.") state + |> Map.put(:running?, false) |> publish_event( OrganizationQuotaExceeded.new!( run_id: id, diff --git a/mix.exs b/mix.exs index c40d5de..80ab9ef 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule GptAgent.MixProject do def project do [ app: :gpt_agent, - version: "9.2.0", + version: "9.2.1", elixir: "~> 1.16", start_permanent: Mix.env() == :prod, aliases: aliases(), diff --git a/test/gpt_agent_test.exs b/test/gpt_agent_test.exs index bf5cfd6..d6e660c 100644 --- a/test/gpt_agent_test.exs +++ b/test/gpt_agent_test.exs @@ -1184,6 +1184,8 @@ defmodule GptAgentTest do refute_receive {^pid, %RunFailed{}}, @retry_delay - 10 + assert :sys.get_state(pid).running? + assert_receive {^pid, %RateLimited{ run_id: ^run_id, @@ -1194,6 +1196,7 @@ defmodule GptAgentTest do 20 refute_receive {^pid, %RunFailed{}}, @retry_delay - 10 + assert :sys.get_state(pid).running? assert_receive {^pid, %RateLimited{ @@ -1210,6 +1213,8 @@ defmodule GptAgentTest do thread_id: ^thread_id, assistant_id: ^assistant_id }} + + refute :sys.get_state(pid).running? end @tag capture_log: true @@ -1272,6 +1277,8 @@ defmodule GptAgentTest do message: "You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors." }} + + refute :sys.get_state(pid).running? end @tag capture_log: true @@ -1328,6 +1335,8 @@ defmodule GptAgentTest do code: ^code, message: ^message }} + + refute :sys.get_state(pid).running? end end