Bug Description
When using ClaudeBox 0.3.1 with Boxlite 0.5.3, creating a ClaudeBox instance and entering the async context fails with:
AttributeError: '_asyncio.Future' object has no attribute '__aenter__'
Root Cause
In claudebox/box.py, the __init__ method calls self._runtime.create() (line 139) which returns an asyncio.Future object. However, since __init__ is synchronous, this Future is never awaited.
Later, in __aenter__ (line 156), the code tries to call await self._box.__aenter__(), but self._box is still a Future object, not a Box instance.
Problem code in box.py:
# Line 139-150 in __init__ (synchronous method)
self._box = self._runtime.create(
BoxOptions(
image=final_image,
cpus=cpus,
...
),
) # Returns Future, not Box!
# Line 155-156 in __aenter__
async def __aenter__(self) -> ClaudeBox:
await self._box.__aenter__() # self._box is Future, has no __aenter__
Steps to Reproduce
import asyncio
from claudebox import ClaudeBox
async def main():
async with ClaudeBox(session_id="test") as box:
result = await box.code("print('hello')")
print(result.response)
asyncio.run(main())
Error Output
Traceback (most recent call last):
File "test.py", line 8, in main
async with ClaudeBox(session_id="test") as box:
File ".../claudebox/box.py", line 156, in __aenter__
await self._box.__aenter__()
AttributeError: '_asyncio.Future' object has no attribute '__aenter__'
Environment
- ClaudeBox version: 0.3.1 (pip shows 0.3.1, but
__version__ in code shows 0.2.0)
- Boxlite version: 0.5.3
- Python: 3.11.14
- OS: macOS Darwin 25.1.0
Suggested Fix
In __aenter__, await the Future before calling __aenter__():
async def __aenter__(self) -> ClaudeBox:
import asyncio
# If self._box is a Future (from runtime.create()), await it first
if asyncio.isfuture(self._box):
self._box = await self._box
await self._box.__aenter__()
# ... rest of the method
Or alternatively, defer the runtime.create() call to __aenter__ where it can be properly awaited.
Additional Notes
-
The __version__ in claudebox/__init__.py is hardcoded as "0.2.0" but pip shows 0.3.1 - this should be updated.
-
The security policy names in documentation/examples may be outdated. Available policies are:
STANDARD_POLICY
READONLY_POLICY
UNRESTRICTED_POLICY
RESTRICTED_POLICY
RESEARCH_POLICY
But some code examples reference STRICT_POLICY and PERMISSIVE_POLICY which don't exist.
Bug Description
When using ClaudeBox 0.3.1 with Boxlite 0.5.3, creating a ClaudeBox instance and entering the async context fails with:
Root Cause
In
claudebox/box.py, the__init__method callsself._runtime.create()(line 139) which returns anasyncio.Futureobject. However, since__init__is synchronous, this Future is never awaited.Later, in
__aenter__(line 156), the code tries to callawait self._box.__aenter__(), butself._boxis still a Future object, not a Box instance.Problem code in box.py:
Steps to Reproduce
Error Output
Environment
__version__in code shows 0.2.0)Suggested Fix
In
__aenter__, await the Future before calling__aenter__():Or alternatively, defer the
runtime.create()call to__aenter__where it can be properly awaited.Additional Notes
The
__version__inclaudebox/__init__.pyis hardcoded as"0.2.0"but pip shows 0.3.1 - this should be updated.The security policy names in documentation/examples may be outdated. Available policies are:
STANDARD_POLICYREADONLY_POLICYUNRESTRICTED_POLICYRESTRICTED_POLICYRESEARCH_POLICYBut some code examples reference
STRICT_POLICYandPERMISSIVE_POLICYwhich don't exist.