Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.
Python aiburrchatbot-frameworkdagsgenerative-aigraphshacktoberfestllmopsllmsmlopspersistent-data-structurestate-machinestate-managementvisibility
Does not allow __ inputs
elijahbenizzy47df91c62e9b
diff --git a/burr/core/application.py b/burr/core/application.pyindex 5eb9c317..0f4f134d 100644--- a/burr/core/application.py+++ b/burr/core/application.py@@ -533,6 +533,14 @@ class Application:return new_statedef _process_inputs(self, inputs: Dict[str, Any], action: Action) -> Dict[str, Any]:+ starting_with_double_underscore = {key for key in inputs.keys() if key.startswith("__")}+ if len(starting_with_double_underscore) > 0:+ raise ValueError(+ ERROR_MESSAGE+ + f"Inputs starting with a double underscore ({starting_with_double_underscore}) "+ f"are reserved for internal use/injected inputs."+ "Please do not use keys"+ )inputs = inputs.copy()processed_inputs = {}required_inputs, optional_inputs = action.optional_and_required_inputsdiff --git a/tests/core/test_application.py b/tests/core/test_application.pyindex a08b5e8b..aa0e523b 100644--- a/tests/core/test_application.py+++ b/tests/core/test_application.py@@ -2471,3 +2471,20 @@ def test_application_with_spawning_parent():assert spawned_by.app_id == "test123"assert spawned_by.partition_key == "user123"assert spawned_by.sequence_id == 5+++def test_application_does_not_allow_dunderscore_inputs():+ """Tests that the context is passed to the function correctly when nulled out.+ TODO -- get this to test without instantiating an application through the builder --+ this is slightly overkill for a bit of code"""+ result_action = Result("count").with_name("result")+ app = (+ ApplicationBuilder()+ .with_actions(result_action)+ .with_entrypoint("result")+ .with_transitions()+ .with_state(count=0)+ .build()+ )+ with pytest.raises(ValueError, match="double underscore"):+ app._process_inputs({"__not_allowed": ...}, app.get_next_action())