Split from #1312.
Summary
In Python bindings, using external_handler with Bash(python=True, external_functions=[...]) can deadlock if the handler callback calls back into the same Bash instance, e.g. via bash.read_file(...) or bash.fs().
This is related to #1312 as motivation, but it is a separate issue from exposing persistent custom builtins on Bash/BashTool.
Repro
from bashkit import Bash
async def read_memory(ctx) -> str:
return ctx["bash"].read_file("/workspace/memory.md")
actions = {"read__memory": read_memory}
bash = Bash(
python=True,
external_functions=["read__memory"],
external_handler=handler,
)
async def handler(fn_name: str, _args: list, kwargs: dict):
ctx = {"bash": bash}
method = actions[fn_name]
return await method(ctx)
Calling the external function from python3 -c ... deadlocks when the callback reaches back into the same Bash instance.
Expected
One of:
- this pattern is explicitly documented as unsupported, with guidance for the intended workflow
- or the Python binding prevents/rejects the re-entrant call cleanly instead of deadlocking
- or the underlying re-entrancy issue is fixed
Notes
Split from #1312.
Summary
In Python bindings, using
external_handlerwithBash(python=True, external_functions=[...])can deadlock if the handler callback calls back into the sameBashinstance, e.g. viabash.read_file(...)orbash.fs().This is related to #1312 as motivation, but it is a separate issue from exposing persistent custom builtins on
Bash/BashTool.Repro
Calling the external function from
python3 -c ...deadlocks when the callback reaches back into the sameBashinstance.Expected
One of:
Notes
Bash/BashToolexternal_handlercallback