feat: make resolve endpoint non-blocking, documentation optional
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -420,7 +420,7 @@ async def resolve_session(
|
||||
db: Annotated[AsyncSession, Depends(get_db)],
|
||||
_: None = Depends(require_engineer_or_admin),
|
||||
):
|
||||
"""Resolve a FlowPilot session and generate documentation."""
|
||||
"""Resolve a session. Returns immediately; use /documentation/stream for ticket notes."""
|
||||
try:
|
||||
result = await flowpilot_engine.resolve_session(
|
||||
session_id=session_id,
|
||||
@@ -433,16 +433,21 @@ async def resolve_session(
|
||||
except PermissionError as e:
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=str(e))
|
||||
|
||||
# Generate resolution outputs (branching feature)
|
||||
try:
|
||||
from app.services.resolution_output_generator import ResolutionOutputGenerator
|
||||
gen = ResolutionOutputGenerator(db)
|
||||
await gen.generate_all(session_id)
|
||||
except Exception:
|
||||
logger.exception(f"Failed to generate resolution outputs for session {session_id}")
|
||||
# Non-blocking — resolve still succeeds even if output generation fails
|
||||
|
||||
await db.commit()
|
||||
|
||||
# Fire-and-forget: resolution outputs (don't block the response)
|
||||
import asyncio
|
||||
|
||||
async def _post_resolve_tasks():
|
||||
try:
|
||||
from app.services.resolution_output_generator import ResolutionOutputGenerator
|
||||
gen = ResolutionOutputGenerator(db)
|
||||
await gen.generate_all(session_id)
|
||||
except Exception:
|
||||
logger.exception(f"Failed to generate resolution outputs for session {session_id}")
|
||||
|
||||
asyncio.create_task(_post_resolve_tasks())
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ class SessionCloseResponse(BaseModel):
|
||||
"""Response after resolving or escalating."""
|
||||
session_id: UUID
|
||||
status: str
|
||||
documentation: SessionDocumentation
|
||||
documentation: SessionDocumentation | None = None
|
||||
psa_push_status: str = "no_psa" # sent | pending_retry | no_psa | failed
|
||||
psa_push_error: str | None = None
|
||||
member_mapping_warning: str | None = None
|
||||
|
||||
@@ -125,7 +125,7 @@ export interface SessionDocumentation {
|
||||
export interface SessionCloseResponse {
|
||||
session_id: string
|
||||
status: string
|
||||
documentation: SessionDocumentation
|
||||
documentation: SessionDocumentation | null
|
||||
psa_push_status: string // "sent" | "pending_retry" | "no_psa" | "failed"
|
||||
psa_push_error: string | null
|
||||
member_mapping_warning: string | null
|
||||
|
||||
Reference in New Issue
Block a user