Reverts PR #16919 (commitsdad10a78d,413ee1a28,b4a8031b2,afb958829) which was merged prematurely. Restoring the pre-merge state so #14817 and #15328 can be revisited as standing PRs. Reverted commits: -afb958829fix(computer-use): harden image-rejection fallback + AUTHOR_MAP -b4a8031b2fix(computer-use): unwrap _multimodal tool results -413ee1a28feat(computer-use): background focus-safe backend -dad10a78dfeat(computer-use): cua-driver backend, universal any-model schema Co-authored-by: teknium1 <teknium@users.noreply.github.com>
This commit is contained in:
@@ -95,31 +95,13 @@ class TestEstimateMessagesTokensRough:
|
||||
assert result == (len(str(msg)) + 3) // 4
|
||||
|
||||
def test_message_with_list_content(self):
|
||||
"""Vision messages with multimodal content arrays.
|
||||
|
||||
Image parts are counted at a flat ~1500-token rate per image
|
||||
rather than counting the base64 char length, so a tiny stub
|
||||
payload still registers as full image cost.
|
||||
"""
|
||||
"""Vision messages with multimodal content arrays."""
|
||||
msg = {"role": "user", "content": [
|
||||
{"type": "text", "text": "describe"},
|
||||
{"type": "image_url", "image_url": {"url": "data:image/png;base64,AAAA"}}
|
||||
]}
|
||||
result = estimate_messages_tokens_rough([msg])
|
||||
# Flat cost = 1500 per image plus the small text overhead. Allow
|
||||
# a small band so this isn't a change-detector for the exact
|
||||
# string representation.
|
||||
assert 1500 <= result < 2000
|
||||
|
||||
def test_message_with_huge_base64_image_stays_bounded(self):
|
||||
"""A 1MB base64 PNG must not explode to ~250K tokens."""
|
||||
huge = "A" * (1024 * 1024)
|
||||
msg = {"role": "tool", "tool_call_id": "c1", "content": [
|
||||
{"type": "text", "text": "x"},
|
||||
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{huge}"}},
|
||||
]}
|
||||
result = estimate_messages_tokens_rough([msg])
|
||||
assert result < 5000
|
||||
assert result == (len(str(msg)) + 3) // 4
|
||||
|
||||
|
||||
# =========================================================================
|
||||
|
||||
Reference in New Issue
Block a user