refs #699: preserve HMM policy MCP evidence
This commit is contained in:
@@ -46,6 +46,12 @@ from src.mcp_tool_router import (
|
||||
build_mcp_tool_arguments,
|
||||
route_mcp_tool_across_servers_with_llm,
|
||||
)
|
||||
from src.mcp_result import (
|
||||
has_actionable_text_result,
|
||||
status_result_evidence,
|
||||
status_result_summary,
|
||||
text_result,
|
||||
)
|
||||
from src.oci_genai_sdk import (
|
||||
build_oci_genai_completion_client,
|
||||
temperature_for_model_profile,
|
||||
@@ -4108,7 +4114,7 @@ def _mcp_summary(mcp_result: Any) -> dict[str, Any]:
|
||||
return {"type": type(mcp_result).__name__}
|
||||
payload = _mcp_response_payload(mcp_result)
|
||||
items = _mcp_items(mcp_result)
|
||||
summary: dict[str, Any] = {}
|
||||
summary: dict[str, Any] = status_result_summary(mcp_result)
|
||||
for key in ("toolName", "profile", "ordsPath", "generatedSql"):
|
||||
value = mcp_result.get(key) if key in mcp_result else payload.get(key)
|
||||
if value:
|
||||
@@ -4195,6 +4201,8 @@ def _clean_agent_tool_query(value: object, fallback: str) -> str:
|
||||
def _mcp_has_actionable_result(mcp_result: Any) -> bool:
|
||||
if _mcp_generated_sql(mcp_result) or _mcp_items(mcp_result):
|
||||
return True
|
||||
if has_actionable_text_result(mcp_result):
|
||||
return True
|
||||
payload = _mcp_response_payload(mcp_result)
|
||||
results = payload.get("results")
|
||||
if isinstance(results, list) and results:
|
||||
@@ -4259,7 +4267,10 @@ def _mcp_answer_evidence(
|
||||
if not isinstance(mcp_result, Mapping):
|
||||
return mcp_result
|
||||
payload = _mcp_response_payload(mcp_result)
|
||||
evidence: dict[str, Any] = {}
|
||||
evidence: dict[str, Any] = status_result_evidence(
|
||||
mcp_result,
|
||||
max_chars=max(3500, min(7000, max_text * 15)),
|
||||
)
|
||||
for key in (
|
||||
"toolName",
|
||||
"profile",
|
||||
@@ -5468,7 +5479,7 @@ def _prepare_hmm_hr_tool_query(
|
||||
"""Prepare an HMM HR query without inheriting retired KB/VPD prompt rules."""
|
||||
|
||||
fallback = str(question or "").strip()
|
||||
if tool.name == "resolve_hr_term":
|
||||
if tool.name in {"resolve_hr_term", "search_hr_policy"}:
|
||||
return fallback
|
||||
contextual_question = _hmm_demo_user_context(
|
||||
fallback,
|
||||
@@ -5646,6 +5657,8 @@ def synthesize_answer(
|
||||
"say that clearly. Treat items_count=0 or results_count=0 as an actual "
|
||||
"zero-row result, not as missing tool delivery. Never claim that an audit "
|
||||
"event exists unless its identifier or audit result is in the evidence. "
|
||||
"For compatibility MCP tools, the result string contains the factual "
|
||||
"DOC and EVIDENCE lines; read it as evidence rather than treating it as metadata. "
|
||||
"For cross-source questions, keep structured contract/product facts separate "
|
||||
"from vector clause evidence, then combine only matching identifiers. If one "
|
||||
"source is missing, list confirmed and unconfirmed points separately instead "
|
||||
@@ -5781,6 +5794,11 @@ def fallback_answer_from_mcp(
|
||||
lines.append(f"- {title or '검색 결과'}{suffix}: {body}")
|
||||
else:
|
||||
lines.append(f"- {compact}")
|
||||
elif text_result(mcp_result):
|
||||
result = text_result(mcp_result)
|
||||
lines.append("")
|
||||
lines.append("MCP 반환 근거:")
|
||||
lines.append(result[:6000] + ("..." if len(result) > 6000 else ""))
|
||||
elif agent_steps:
|
||||
lines.append(f"Agent는 MCP tool을 {len(agent_steps)}회 호출했습니다.")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user