fix: preserve raw intent across language switching
This commit is contained in:
@@ -54,6 +54,7 @@ class RouterAgent(BaseAgent):
|
||||
"history": history,
|
||||
"session_id": str(payload.get("session_id") or state.session_id),
|
||||
"job_id": str(payload.get("job_id") or state.job_id),
|
||||
"language": str(payload.get("language") or "zh"),
|
||||
}
|
||||
if "goal_ledger" in payload:
|
||||
runtime_context["goal_ledger"] = payload.get("goal_ledger")
|
||||
|
||||
@@ -1174,6 +1174,7 @@ class RouterRuntime:
|
||||
session_id: str,
|
||||
job_id: str,
|
||||
goal_ledger: GoalLedger | None = None,
|
||||
language: str = "zh",
|
||||
) -> RouterOutcome:
|
||||
ui_action = self._config_dialog_ui_action(query)
|
||||
if ui_action is not None:
|
||||
@@ -1399,6 +1400,7 @@ class RouterRuntime:
|
||||
job_id,
|
||||
decision,
|
||||
goal_ledger,
|
||||
language,
|
||||
)
|
||||
definitions = self._definitions_for_route(
|
||||
decision,
|
||||
@@ -2127,6 +2129,7 @@ class RouterRuntime:
|
||||
job_id: str,
|
||||
decision: RouteDecision,
|
||||
goal_ledger: GoalLedger | None,
|
||||
language: str = "zh",
|
||||
) -> list[LLMMessage]:
|
||||
normalized = []
|
||||
for item in history:
|
||||
@@ -2150,6 +2153,12 @@ class RouterRuntime:
|
||||
f"\nTrusted locked route context: {route_context}."
|
||||
f"\nCurrent session_id={session_id!r}; current job_id={job_id!r}."
|
||||
)
|
||||
if str(language or "zh").strip().lower() == "en":
|
||||
context += (
|
||||
"\nRespond to the user in English. Treat the language preference as "
|
||||
"presentation metadata; do not rewrite the user query or pass the "
|
||||
"language instruction to intent-recognition tools."
|
||||
)
|
||||
if goal_ledger is not None:
|
||||
ledger_context = json.dumps(
|
||||
goal_ledger.model_dump(mode="json", round_trip=True),
|
||||
|
||||
Reference in New Issue
Block a user