mohitdixit02 opened a new pull request, #1019: URL: https://github.com/apache/burr/pull/1019
Resolves #1017. In `stream_result()` and `astream_result()`, raw `inputs` were passed to `pre_run_step` hooks before `_process_inputs()` was called. This caused hooks to miss framework-injected dependencies (e.g., `__context`, `__tracer`) and see undeclared inputs that the action never receives. Furthermore, input validation failures (e.g., passing `__reserved` parameters or omitting required inputs) occurred after `pre_run_step` and sequence incrementation had already fired, leaving hook lifecycle state dangling (such as `token_pointer_map` in `TracerFactoryContextHook`). ## Changes 1. **`stream_result()` & `astream_result()` in `burr/core/application.py`**: - Moved `_process_inputs()` before `_increment_sequence_id()`. - Passed `action_inputs` directly to `pre_run_step` hooks so injected dependencies are present and undeclared inputs are excluded. - Any validation error in `_process_inputs()` now aborts immediately before sequence IDs are incremented or any hook is executed, preventing orphaned `pre_run_step` entries and `KeyError` crashes in `post_run_step`. 2. **`_step()` and `_astep()`**: - Added an internal `_processed_inputs` argument. When halting at a non-streaming action in `stream_result` or `astream_result`, the already-processed inputs are forwarded directly to `_step` / `_astep` so dependency factory calls are not duplicated. 3. **Tests (`tests/core/test_application.py`)**: - Added `test_stream_result_processes_inputs_before_pre_run_step_hook`: verifies `pre_run_step` receives `__context` and does not receive undeclared inputs across both sync and async streaming. - Added `test_stream_result_validates_inputs_before_pre_run_step_hook`: verifies validation errors abort cleanly without firing `pre_run_step` or `post_run_step`. - Added `test_stream_result_shares_one_processed_inputs_dict`: verifies dependency factories are called exactly once during non-streaming halts. ## How I tested this - Ran the full core test suite: `pytest tests/core/test_application.py` (145/145 passed). - Verified against the author's reproduction script in #1017; `step`, `stream_result`, and `astream_result` now report identical hook inputs `['__context', 'value']`. - Verified Apache license header check passed: `python scripts/check_asf_headers.py`. ## Checklist - [x] PR has an informative and human-readable title (this will be pulled into the release notes) - [x] Changes are limited to a single goal (no scope creep) - [x] Code passed the pre-commit check & code is left cleaner/nicer than when first encountered. - [x] Any _change_ in functionality is tested - [x] New functions are documented (with a description, list of inputs, and expected output) - [x] Placeholder code is flagged / future TODOs are captured in comments - [x] Project documentation has been updated if adding/changing functionality. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
