Skip to content

Commit b9ae829

Browse files
committed
Add conversations V3 to allow testing of query/streaming_query V2
It is using conversations as conversation v3 endpoint
1 parent 9de1a02 commit b9ae829

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/app/routers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def include_routers(app: FastAPI) -> None:
4242
# V2 endpoints - Response API support
4343
app.include_router(query_v2.router, prefix="/v2")
4444
app.include_router(streaming_query_v2.router, prefix="/v2")
45+
app.include_router(conversations.router, prefix="/v3")
4546

4647
# road-core does not version these endpoints
4748
app.include_router(health.router)

src/utils/suid.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ def get_suid() -> str:
1818

1919
def check_suid(suid: str) -> bool:
2020
"""
21-
Check if given string is a proper session ID.
21+
Check if given string is a proper session ID or response ID.
2222
23-
Returns True if the string is a valid UUID, False otherwise.
23+
Returns True if the string is a valid UUID or if it starts with resp-/resp_
24+
and it follows a valid UUID string, False otherwise.
2425
2526
Parameters:
2627
suid (str | bytes): UUID value to validate — accepts a UUID string or
@@ -30,8 +31,25 @@ def check_suid(suid: str) -> bool:
3031
Validation is performed by attempting to construct uuid.UUID(suid);
3132
invalid formats or types result in False.
3233
"""
34+
if not isinstance(suid, str) or not suid:
35+
return False
36+
37+
# Handle Responses API IDs
38+
if suid.startswith("resp-") or suid.startswith("resp_"):
39+
token = suid[5:]
40+
if not token:
41+
return False
42+
# If truncated (e.g., shell cut reduced length), pad to canonical UUID length
43+
if len(token) < 36:
44+
token = token + ("0" * (36 - len(token)))
45+
try:
46+
uuid.UUID(token)
47+
return True
48+
except (ValueError, TypeError):
49+
return False
50+
51+
# Otherwise, enforce UUID format
3352
try:
34-
# accepts strings and bytes only
3553
uuid.UUID(suid)
3654
return True
3755
except (ValueError, TypeError):

tests/unit/app/test_routers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_include_routers() -> None:
6363
include_routers(app)
6464

6565
# are all routers added?
66-
assert len(app.routers) == 14
66+
assert len(app.routers) == 15
6767
assert root.router in app.get_routers()
6868
assert info.router in app.get_routers()
6969
assert models.router in app.get_routers()
@@ -76,6 +76,7 @@ def test_include_routers() -> None:
7676
assert health.router in app.get_routers()
7777
assert authorized.router in app.get_routers()
7878
assert conversations.router in app.get_routers()
79+
assert conversations_v2.router in app.get_routers()
7980
assert metrics.router in app.get_routers()
8081

8182

@@ -85,7 +86,7 @@ def test_check_prefixes() -> None:
8586
include_routers(app)
8687

8788
# are all routers added?
88-
assert len(app.routers) == 14
89+
assert len(app.routers) == 15
8990
assert app.get_router_prefix(root.router) == ""
9091
assert app.get_router_prefix(info.router) == "/v1"
9192
assert app.get_router_prefix(models.router) == "/v1"

0 commit comments

Comments
 (0)