Conversation
A class-based action that declares `__context` (or `__tracer`) in its run signature has that parameter name-mangled by Python, e.g. to `_MyAction__context`. The sync run path remaps the injected input to the mangled name, but the async run path and both multi-step streaming paths passed `__context=` as-is, so the action failed with `TypeError: run() got an unexpected keyword argument '__context'`. Apply the same remap in `_arun_function` and in the sync and async multi-step streaming runners. Generated-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
sangkyoonnam
left a comment
There was a problem hiding this comment.
This looks correct to me. Thanks for writing out the red/green runs, they made this quick to check.
I ran each class-based action shape on main (8161159) and the head. Action with async def run, StreamingAction and AsyncStreamingAction raise TypeError on main and pass on the head, for both __context and __tracer. The three new tests fail on main and pass on the head, and tests/core is 403 passed.
The single-step runners at application.py lines 322, 344, 412 and 598 sit outside the diff. This still raises TypeError: Ctx.run_and_update() got an unexpected keyword argument '__context' on the head:
class Ctx(SingleStepAction):
reads, writes, inputs = [], ["x"], ["__context"]
def run_and_update(self, state, __context):
r = {"x": __context.app_id}
return r, state.update(**r)The docstring calls SingleStepAction internal and in-tree subclasses take **run_kwargs, so leaving it out makes sense. Would a one-line TODO at those sites help the next person who hits it?
Class-based actions can take the injected
__context(or__tracer) as arunparameter, but that only works on the sync, non-streaming path. Anasync def run(self, state, __context)action, or aStreamingAction/AsyncStreamingActionwhosestream_runtakes__context, fails when it runs:Inside a class body, Python name-mangles
__contextto_ClassName__context. #449 and #452 fixed this for_run_functionby remapping the injected inputs to the mangled names with_remap_dunder_parameters._arun_function,_run_multi_step_streaming_actionand_arun_multi_step_streaming_actionstill pass__context=unchanged.Changes
burr/core/application.py: add a small_remap_injected_inputs(method, inputs)helper that wraps the existing check-and-remap from_run_function. Call it in_run_function(behavior unchanged),_arun_function, and the sync and async multi-step streaming runners, onstream_run.runtakes**run_kwargs, so no parameter name ends in__contextand the inputs pass through unchanged.tests/core/test_application.py: three end-to-end regressions that build an app with a class-based action reading__context.app_id. They go throughastep(),stream_result()andastream_result().How I tested this
main(8161159), the three new tests fail with theTypeErrors above.pytest tests/core: 403 passed (with thegraphvizpackage installed; without it, only the existing graphviz display tests fail, the same as onmain).--line-length=100), isort 5.12.0 and flake8 6.1.0 at the pre-commit pins are clean on the changed files.git diff --checkis clean.Notes
run()path has had the remap since late 2024 (Fixes __context for classed based actions #449 / Fixes __tracer for class based actions #452). This change brings the async and streaming class APIs to parity. The single-step internal classes (SingleStepAction,SingleStepStreamingAction) are documented as not user-facing, so I left them alone to keep the change focused.Checklist
_remap_injected_inputsis a private helper with a docstring)__contextdocs)AI disclosure (per the ASF Generative Tooling guidance): an AI coding tool (Claude Code, Claude Opus 5.5) wrote this change through the
breken-aiaccount. The tool found the bug, wrote the fix and the tests, and wrote this description. The commit carries aGenerated-by:trailer. The diff is a small original change to existing Burr code and includes no third-party material. The red/green runs above are real, and you can re-run them from the diff. If you would rather not take AI-assisted contributions here, say so and I will close this.🤖 Generated with Claude Code