legend91019 commented on PR #995:
URL: https://github.com/apache/burr/pull/995#issuecomment-6489182451

   Thanks @xihaian251 — the sync branch is fixed in `7a58bba`, now at the head 
of this PR.
   
   **Fix.** `_step` takes an optional `_processed_inputs` dict, and the sync 
branch of `_astep` passes the dict it already processed:
   
   ```python
   output = self._step(
       inputs=inputs,
       _run_hooks=False,
       _processed_inputs=action_inputs,
   )
   ```
   
   Same shape as #980. Your note about feeding `action_inputs` back through 
`inputs=` was the deciding constraint: `_process_inputs` rejects the 
`__context` key, so it had to be a separate parameter rather than a reuse of 
`inputs`.
   
   **Regression test.** Added 
`test_step_and_astep_share_one_processed_inputs_dict` in 
`tests/core/test_application.py`, parametrised over `step()`, `astep()` with a 
sync action and `astep()` with an async action. It swaps the `__context` 
factory for one that returns a fresh `object()` per call, then asserts a single 
factory call plus identity between the object in the hook's `inputs` and the 
object the action received.
   
   Negative control, test unchanged, only the production change reverted 
(Python 3.14.6, Windows):
   
   ```text
   astep(), sync action : FAILED - __context factory ran 2 times, expected once
   step(),  sync action : passed
   astep(), async action: passed
   ```
   
   That is the same two-case split you reported.
   
   **`astream_result`.** The count goes back to `main`'s two instead of the 
three on `3ff45707`, as a side effect of the same change. Counts below 
instrument `_process_inputs` itself, so they are direct calls rather than 
factory invocations:
   
   ```text
                          3ff45707   this commit   main
   step(),  sync action       1           1          1
   astep(), sync action       2           1          1
   astep(), async action      1           1          1
   astream_result()           3           2          2
   ```
   
   I left `astream_result` itself alone: it still calls `_astep(inputs=inputs, 
_run_hooks=False)` with the original dict, so that path processes twice, but no 
hooks run there, so the identities cannot diverge. Collapsing it to a single 
call is a separate change if you want it.
   
   **Runs.** `tests/core/test_application.py`: 147 passed. `tests/core` without 
the Graphviz rendering tests: 427 passed. The four `test_graphviz_display.py` 
cases fail in this environment with `ExecutableNotFound: failed to execute 
'dot'` (`dot` is not on PATH), unrelated to this change. flake8 and isort are 
clean; `black --check` flags `tests/core/test_application.py`, but it flags the 
base file the same way, and I kept the existing quoting style of the file.
   
   Happy to take your focused test as well if it covers a case mine misses — 
otherwise I think this one pins the behaviour you reproduced.
   


-- 
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]

Reply via email to