chore: minor cleanup

This commit is contained in:
Alex committed 2026-08-22 14:41:17 +01:00
1 parent 3f88dc7b57
commit 5f96c67e78
5 files changed
+39 -26

No files matched your search

+3 -1
View File
@@ -9,6 +9,7 @@ from application.api import api
from application.api.answer.routes.base import answer_ns, BaseAnswerResource
from application.api.answer.services.continuation_service import (
RESUME_IN_PROGRESS_MESSAGE,
ResumeInProgressError,
)
from application.api.answer.services.persistence_policy import resolve_persistence
@@ -179,7 +180,8 @@ class AnswerResource(Resource, BaseAnswerResource):
extra={"error": str(e)},
)
return make_response(
{"error": str(e), "code": "resume_in_progress"}, 409,
{"error": RESUME_IN_PROGRESS_MESSAGE, "code": "resume_in_progress"},
409,
)
except Exception as e:
logger.error(
+2 -1
View File
@@ -9,6 +9,7 @@ from application.api import api
from application.api.answer.routes.base import answer_ns, BaseAnswerResource
from application.api.answer.services.continuation_service import (
RESUME_IN_PROGRESS_MESSAGE,
ResumeInProgressError,
)
from application.api.answer.services.persistence_policy import resolve_persistence
@@ -192,7 +193,7 @@ class StreamResource(Resource, BaseAnswerResource):
extra={"error": str(e)},
)
return Response(
self.error_stream_generate(str(e)),
self.error_stream_generate(RESUME_IN_PROGRESS_MESSAGE),
status=409,
mimetype="text/event-stream",
)
@@ -35,6 +35,12 @@ class ResumeInProgressError(ValueError):
"""Raised when another request already owns a continuation claim."""
# The single wording every route answers this condition with. Handlers render
# this constant rather than ``str(exc)`` so no exception text — and nothing an
# exception might later be constructed from — can reach a response body.
RESUME_IN_PROGRESS_MESSAGE = "Resume already in progress for this conversation."
class ContinuationService:
"""Manages pending tool-call state in Postgres."""
@@ -147,9 +153,7 @@ class ContinuationService:
return claimed
existing = repo.load_state_any(pg_conv_id, user)
if existing and existing.get("status") == "resuming":
raise ResumeInProgressError(
"Resume already in progress for this conversation."
)
raise ResumeInProgressError(RESUME_IN_PROGRESS_MESSAGE)
return None
def delete_state(self, conversation_id: str, user: str) -> bool:
+2 -1
View File
@@ -18,6 +18,7 @@ from application.api.answer.routes.base import BaseAnswerResource
from application.api.answer.services.persistence_policy import resolve_persistence
from application.api.answer.services.continuation_service import (
ContinuationService,
RESUME_IN_PROGRESS_MESSAGE,
ResumeInProgressError,
)
from application.api.answer.services.stream_processor import StreamProcessor
@@ -425,7 +426,7 @@ def chat_completions():
return make_response(
jsonify({
"error": {
"message": "Resume already in progress for this conversation.",
"message": RESUME_IN_PROGRESS_MESSAGE,
"type": "conflict_error",
"code": "resume_in_progress",
}