Ajustes conforme relatorio de testes 2026-08-27
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -30,6 +30,29 @@ class FaturasAgent(AgentRuntimeMixin):
|
||||
self.summary_memory = summary_memory
|
||||
self.guardrail_pipeline = guardrail_pipeline
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _handoff_patch_from_tool_context(tool_context):
|
||||
for item in tool_context or []:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
data = item.get("result")
|
||||
if not isinstance(data, dict):
|
||||
continue
|
||||
nested = data.get("result")
|
||||
if isinstance(nested, dict) and nested.get("session_control"):
|
||||
data = nested
|
||||
if str(data.get("session_control") or "").upper() != "HUMAN_HANDOFF":
|
||||
continue
|
||||
return {
|
||||
"session_control": "HUMAN_HANDOFF",
|
||||
"human_handoff_requested": True,
|
||||
"session_ended": True,
|
||||
"terminal_status": str(data.get("terminal_status") or "human_handoff"),
|
||||
"handoff_reason": str(data.get("handoff_reason") or ""),
|
||||
}
|
||||
return {}
|
||||
|
||||
async def run(self, state):
|
||||
await self._emit_ic(
|
||||
"IC.FATURAS_AGENT_STARTED",
|
||||
@@ -48,6 +71,7 @@ class FaturasAgent(AgentRuntimeMixin):
|
||||
)
|
||||
|
||||
state["mcp_results"] = tool_context
|
||||
handoff_patch = self._handoff_patch_from_tool_context(tool_context)
|
||||
clarification_message = self.transaction_clarification_message(state)
|
||||
if clarification_message:
|
||||
return {
|
||||
@@ -55,6 +79,7 @@ class FaturasAgent(AgentRuntimeMixin):
|
||||
"next_state": state.get("next_state") or "COLLECTING_PARAMETERS",
|
||||
"mcp_results": tool_context,
|
||||
**self.transaction_state_patch(state),
|
||||
**handoff_patch,
|
||||
}
|
||||
|
||||
confirmation_message = self.transaction_confirmation_message(state)
|
||||
@@ -64,6 +89,7 @@ class FaturasAgent(AgentRuntimeMixin):
|
||||
"next_state": state.get("next_state"),
|
||||
"mcp_results": tool_context,
|
||||
**self.transaction_state_patch(state),
|
||||
**handoff_patch,
|
||||
}
|
||||
return result
|
||||
|
||||
@@ -75,6 +101,7 @@ class FaturasAgent(AgentRuntimeMixin):
|
||||
"mcp_results": tool_context,
|
||||
"rag": {"enabled": False, "skipped": True, "reason": "direct_mcp_answer"},
|
||||
**self.transaction_state_patch(state),
|
||||
**handoff_patch,
|
||||
}
|
||||
|
||||
rag_context, rag_metadata = await self._retrieve_rag_context(state)
|
||||
@@ -113,6 +140,7 @@ class FaturasAgent(AgentRuntimeMixin):
|
||||
"rag": rag_metadata,
|
||||
"memory_context_metadata": state.get("memory_context_metadata"),
|
||||
**self.transaction_state_patch(state),
|
||||
**handoff_patch,
|
||||
}
|
||||
|
||||
await self._emit_ic(
|
||||
|
||||
Reference in New Issue
Block a user