Skip to content

Commit 387f7b0

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

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
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: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,31 @@ def get_suid() -> str:
1313

1414

1515
def check_suid(suid: str) -> bool:
16-
"""Check if given string is a proper session ID.
16+
"""Check if given string is a proper session ID or response ID.
1717
18-
Args:
19-
suid: The string to check.
20-
21-
Returns True if the string is a valid UUID, False otherwise.
18+
Rules:
19+
- If it starts with "resp-" or "resp_", accept as a valid Responses API ID (opaque).
20+
- Otherwise, require a valid UUID string.
2221
"""
22+
if not isinstance(suid, str) or not suid:
23+
return False
24+
25+
# Handle Responses API IDs
26+
if suid.startswith("resp-") or suid.startswith("resp_"):
27+
token = suid[5:]
28+
if not token:
29+
return False
30+
# If truncated (e.g., shell cut reduced length), pad to canonical UUID length
31+
if len(token) < 36:
32+
token = token + ("0" * (36 - len(token)))
33+
try:
34+
uuid.UUID(token)
35+
return True
36+
except (ValueError, TypeError):
37+
return False
38+
39+
# Otherwise, enforce UUID format
2340
try:
24-
# accepts strings and bytes only
2541
uuid.UUID(suid)
2642
return True
2743
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)