31 lines
1.4 KiB
Python
31 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from agent_framework.runtime.agent_runtime import AgentRuntimeMixin
|
|
|
|
|
|
def test_framework_detecta_instrucao_de_composicao_llm_recursiva():
|
|
results=[{"ok":True,"result":{"output":{"orientar":{"requires_llm_composition":True,"response_instruction":"Explique a devolução."}}}}]
|
|
required, instructions = AgentRuntimeMixin._mcp_llm_composition_directive(results)
|
|
assert required is True
|
|
assert instructions == ["Explique a devolução."]
|
|
|
|
|
|
def test_direct_answer_eh_desabilitada_quando_tool_exige_composicao_llm():
|
|
runtime=AgentRuntimeMixin()
|
|
results=[{"ok":True,"tool_name":"pro_rata","result":{"requires_llm_composition":True,"response_instruction":"Explique."}}]
|
|
assert runtime.build_direct_mcp_answer({"user_text":"explique"}, results, agent_label="Contas") is None
|
|
|
|
|
|
def test_pro_rata_orientacao_declara_composicao_no_llm_do_framework():
|
|
from app.domain.contas.workflow_actions import build_contas_workflow_actions
|
|
|
|
class Service: pass
|
|
reg=build_contas_workflow_actions(Service()) # type: ignore[arg-type]
|
|
result=reg.get("orientar_pagamento_pro_rata")(
|
|
{"devolucao":{"format_text":"conta_futura","items":[{"itemName":"Plano","validatedAmount":3.06}]}},
|
|
{"input":{}},
|
|
)
|
|
assert result["requires_llm_composition"] is True
|
|
assert result["devolucao"]["format_text"] == "conta_futura"
|
|
assert "devolução" in result["response_instruction"]
|