Enhance workflow state tracking by passing and utilizing selection mode in agent runtimes
This commit is contained in:
@@ -605,7 +605,12 @@ class WorkflowRuntime:
|
||||
session_pk=session.id, role="assistant", content=content,
|
||||
sources_json=json.dumps(sources, ensure_ascii=False, default=str),
|
||||
workflow_id=run.workflow_id, workflow_revision_id=run.workflow_revision_id, workflow_run_id=run.id,
|
||||
agent_summary_json=json.dumps({"tool_calls": counters["tool_calls"], "llm_calls": counters["llm_calls"], "duration_seconds": duration}),
|
||||
agent_summary_json=json.dumps({
|
||||
"tool_calls": counters["tool_calls"],
|
||||
"llm_calls": counters["llm_calls"],
|
||||
"duration_seconds": duration,
|
||||
"selection_mode": run.selection_mode,
|
||||
}),
|
||||
usage_json=json.dumps(usage),
|
||||
))
|
||||
db.commit()
|
||||
|
||||
@@ -218,16 +218,17 @@ export function createChatGenerationHandlers({
|
||||
const currentSelection = getChatWorkflowForSession(sessionId) || { mode: 'direct', workflowId: null }
|
||||
const originalAssistant = msgs.slice(lastUserIdx + 1).find(message => message?.role === 'assistant')
|
||||
const originalWorkflowId = originalAssistant?.workflow_id || null
|
||||
const originalSelectionMode = originalAssistant?.agent_summary?.selection_mode || null
|
||||
let selection = currentSelection
|
||||
let workflowRevisionId = null
|
||||
if (currentSelection.mode === 'automatic' && originalWorkflowId) {
|
||||
if (currentSelection.mode === 'automatic' && originalSelectionMode === 'automatic' && originalWorkflowId) {
|
||||
selection = { mode: 'explicit', workflowId: originalWorkflowId }
|
||||
workflowRevisionId = originalAssistant?.workflow_revision_id || null
|
||||
} else if (
|
||||
originalWorkflowId
|
||||
&& (
|
||||
(currentSelection.mode === 'explicit' && currentSelection.workflowId === originalWorkflowId)
|
||||
|| (currentSelection.mode === 'direct' && originalWorkflowId === 'input-output')
|
||||
(currentSelection.mode === 'explicit' && originalSelectionMode === 'explicit' && currentSelection.workflowId === originalWorkflowId)
|
||||
|| (currentSelection.mode === 'direct' && originalSelectionMode === 'direct')
|
||||
)
|
||||
) {
|
||||
workflowRevisionId = originalAssistant?.workflow_revision_id || null
|
||||
|
||||
Reference in New Issue
Block a user