test(vertex_ai): align signature tests with checksummed tool call ids

Rework onto main renamed the helpers to public names and upstream added
factory tests pinning the pre-checksum wire format, so update those
expectations to the checksummed layout and use a valid base64 signature
for the embedded-id round trip.
This commit is contained in:
libaojiang 2026-10-12 22:53:26 +08:00
parent 8a5d679e17
commit 7be5d7899b
2 changed files with 15 additions and 6 deletions

View file

@ -1,4 +1,4 @@
import asyncio, base64, importlib, uuid
import asyncio, base64, hashlib, importlib, uuid
import json
import logging
import os
@ -83,7 +83,12 @@ def test_function_call_prompt_lets_the_model_answer_after_a_function_result() ->
@pytest.mark.parametrize(
("thought_signature", "expected"),
[
("encoded-signature", "call_123__thought__encoded-signature"),
(
"encoded-signature",
"call_123__checksum__"
+ hashlib.sha256(b"encoded-signature").hexdigest()
+ "__thought__encoded-signature",
),
(None, "call_123"),
("", "call_123"),
],
@ -101,8 +106,12 @@ def test_encode_tool_call_id_with_signature(thought_signature, expected):
"function-signature",
),
(
{"id": encode_tool_call_id_with_signature("call_123", "embedded-signature")},
"embedded-signature",
{
"id": encode_tool_call_id_with_signature(
"call_123", "ZW1iZWRkZWQtc2lnbmF0dXJl"
)
},
"ZW1iZWRkZWQtc2lnbmF0dXJl",
),
({}, None),
],

View file

@ -322,13 +322,13 @@ def test_get_thought_signature_rejects_decodable_tampering():
)
assert _is_valid_thought_signature(decodable_but_wrong) is True
assert _get_thought_signature_from_tool({"id": tampered_id, "type": "function"}) is None
assert get_thought_signature_from_tool({"id": tampered_id, "type": "function"}) is None
def test_get_thought_signature_rejects_unsigned_embedded_signature():
unsigned_id = f"call_abc123{THOUGHT_SIGNATURE_SEPARATOR}{REAL_SIGNATURE}"
assert _get_thought_signature_from_tool({"id": unsigned_id, "type": "function"}) is None
assert get_thought_signature_from_tool({"id": unsigned_id, "type": "function"}) is None
def test_get_thought_signature_drops_client_mangled_id_suffix():