feat: integrate branching into chat service and step creation
Add is_branching guard to unified_chat_service.send_chat_message() that routes messages through BranchAwarePromptBuilder when a session has active branching. Add branch_id to all AISessionStep constructor calls in flowpilot_engine.py via optional branch_id param on _create_step_from_parsed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -319,6 +319,7 @@ async def start_session(
|
||||
parsed=parsed,
|
||||
input_tokens=input_tokens,
|
||||
output_tokens=output_tokens,
|
||||
branch_id=session.active_branch_id if session.is_branching else None,
|
||||
)
|
||||
db.add(step)
|
||||
|
||||
@@ -421,6 +422,7 @@ async def process_response(
|
||||
parsed=parsed,
|
||||
input_tokens=input_tokens,
|
||||
output_tokens=output_tokens,
|
||||
branch_id=session.active_branch_id if session.is_branching else None,
|
||||
)
|
||||
db.add(step)
|
||||
|
||||
@@ -640,6 +642,7 @@ async def pickup_session(
|
||||
briefing_step = AISessionStep(
|
||||
id=uuid.uuid4(),
|
||||
session_id=session.id,
|
||||
branch_id=session.active_branch_id if session.is_branching else None,
|
||||
step_order=session.step_count,
|
||||
step_type="action",
|
||||
content={
|
||||
@@ -714,6 +717,7 @@ async def pickup_session(
|
||||
parsed=parsed,
|
||||
input_tokens=input_tokens,
|
||||
output_tokens=output_tokens,
|
||||
branch_id=session.active_branch_id if session.is_branching else None,
|
||||
)
|
||||
db.add(next_step)
|
||||
|
||||
@@ -926,6 +930,7 @@ async def generate_status_update(
|
||||
step = AISessionStep(
|
||||
id=uuid.uuid4(),
|
||||
session_id=session.id,
|
||||
branch_id=session.active_branch_id if session.is_branching else None,
|
||||
step_order=session.step_count,
|
||||
step_type="status_update",
|
||||
content={
|
||||
@@ -1207,6 +1212,7 @@ def _create_step_from_parsed(
|
||||
parsed: dict[str, Any],
|
||||
input_tokens: int,
|
||||
output_tokens: int,
|
||||
branch_id: UUID | None = None,
|
||||
) -> AISessionStep:
|
||||
"""Create an AISessionStep from parsed LLM output."""
|
||||
step_type = parsed["type"]
|
||||
@@ -1244,6 +1250,7 @@ def _create_step_from_parsed(
|
||||
return AISessionStep(
|
||||
id=uuid.uuid4(),
|
||||
session_id=session_id,
|
||||
branch_id=branch_id,
|
||||
step_order=step_order,
|
||||
step_type=step_type if parsed["type"] != "resolution_suggestion" else "action",
|
||||
content=content,
|
||||
|
||||
Reference in New Issue
Block a user