mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-09 12:40:59 +00:00
fix(agent): harden runner integration and QA
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
The web debug client uploads Image / Voice / File components carrying a storage
|
||||
key in ``path``. This helper resolves each to a base64 data URI (so multimodal
|
||||
LLM input and the Box sandbox inbox have usable bytes), then deletes the
|
||||
consumed storage object and clears ``path``. Covers mimetype selection per
|
||||
type and fail-closed error handling.
|
||||
LLM input and the Box sandbox inbox have usable bytes) while retaining the key
|
||||
for browser history. Covers mimetype selection per type and fail-closed error
|
||||
handling.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -52,7 +52,7 @@ def _make_adapter(load_return=b'hello', load_side_effect=None):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_image_jpeg_mimetype_and_cleanup():
|
||||
async def test_image_jpeg_mimetype_and_retained_storage_key():
|
||||
adapter, storage_mgr, _ = _make_adapter(load_return=b'\xff\xd8\xff')
|
||||
path = f'{_UPLOAD_PREFIX}photo.jpg'
|
||||
chain = [{'type': 'Image', 'path': path}]
|
||||
@@ -61,12 +61,24 @@ async def test_image_jpeg_mimetype_and_cleanup():
|
||||
|
||||
expected_b64 = base64.b64encode(b'\xff\xd8\xff').decode('utf-8')
|
||||
assert chain[0]['base64'] == f'data:image/jpeg;base64,{expected_b64}'
|
||||
assert chain[0]['path'] == '' # consumed
|
||||
storage_mgr.delete_scoped_object_key.assert_awaited_once_with(
|
||||
_CONTEXT,
|
||||
path,
|
||||
expected_owner_type='upload_image',
|
||||
)
|
||||
assert chain[0]['path'] == path
|
||||
storage_mgr.delete_scoped_object_key.assert_not_awaited()
|
||||
|
||||
|
||||
def test_history_retains_storage_key_without_large_base64_payload():
|
||||
path = f'{_UPLOAD_PREFIX}photo.jpg'
|
||||
chain = [
|
||||
{
|
||||
'type': 'Image',
|
||||
'path': path,
|
||||
'base64': 'data:image/jpeg;base64,large-payload',
|
||||
}
|
||||
]
|
||||
|
||||
history = WebSocketAdapter._history_message_chain(chain)
|
||||
|
||||
assert history == [{'type': 'Image', 'path': path, 'base64': ''}]
|
||||
assert chain[0]['base64'] == 'data:image/jpeg;base64,large-payload'
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user