Skip to content

A programming framework for agentic AI

Decrement the count of outstanding tasks before returning in the event of an exception. (#406)

Enhao Zhang62e5e5b88d1a
diff --git a/python/src/agnext/application/_single_threaded_agent_runtime.py b/python/src/agnext/application/_single_threaded_agent_runtime.py
index 833e29d1d..4170a8735 100644
--- a/python/src/agnext/application/_single_threaded_agent_runtime.py
+++ b/python/src/agnext/application/_single_threaded_agent_runtime.py
@@ -272,6 +272,7 @@ class SingleThreadedAgentRuntime(AgentRuntime):
)
except BaseException as e:
message_envelope.future.set_exception(e)
+ self._outstanding_tasks.decrement()
return
self._message_queue.append(
@@ -327,6 +328,7 @@ class SingleThreadedAgentRuntime(AgentRuntime):
except BaseException as e:
# Ignore cancelled errors from logs
if isinstance(e, CancelledError):
+ self._outstanding_tasks.decrement()
return
logger.error("Error processing publish message", exc_info=True)
finally: