Skip to content

armgit / burr

Public Imported from GitHub
0

Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.

Fixes bug in which lifecycle hook got passed null action

elijahbenizzy760ac288da19
diff --git a/burr/core/application.py b/burr/core/application.py
index c5d19d61..bb801e02 100644
--- a/burr/core/application.py
+++ b/burr/core/application.py
@@ -211,13 +211,13 @@ class Application:
:return: Tuple[Function, dict, State] -- the function that was just ran, the result of running it, and the new state
"""
next_action = self.get_next_action()
+ if next_action is None:
+ return None
if inputs is None:
inputs = {}
self._adapter_set.call_all_lifecycle_hooks_sync(
"pre_run_step", action=next_action, state=self._state
)
- if next_action is None:
- return None
exc = None
result = None
new_state = self._state
diff --git a/tests/core/test_application.py b/tests/core/test_application.py
index 8391fefc..a178e7c7 100644
--- a/tests/core/test_application.py
+++ b/tests/core/test_application.py
@@ -792,6 +792,8 @@ def test_application_run_step_hooks_sync():
assert set(tracker.post_called) == {"counter", "result"}
assert len(tracker.pre_called) == 11
assert len(tracker.post_called) == 11
+ # quick inclusion to ensure that the action is not called when we're done running
+ assert app.step() is None # should be None
async def test_application_run_step_hooks_async():