fix(agent): finalize max-iteration turns without tools

This commit is contained in:
chengyongru
2026-06-10 14:47:20 +08:00
committed by Xubin Ren
parent 99f7f371fa
commit 5d91d59cf7
9 changed files with 199 additions and 18 deletions
+13
View File
@@ -24,6 +24,14 @@ FINALIZATION_RETRY_PROMPT = (
"Please provide your response to the user based on the conversation above."
)
BUDGET_EXHAUSTED_FINALIZATION_PROMPT = (
"The tool-call budget for this turn is exhausted. Based only on the "
"conversation and tool results above, provide a concise final response to "
"the user. Do not call or request tools. Do not claim the task is complete "
"unless the evidence above clearly shows it is complete. State what was "
"done, what remains, and the best next step if anything is incomplete."
)
LENGTH_RECOVERY_PROMPT = (
"Output limit reached. Continue exactly where you left off "
"— no recap, no apology. Break remaining work into smaller steps if needed."
@@ -65,6 +73,11 @@ def build_finalization_retry_message() -> dict[str, str]:
return {"role": "user", "content": FINALIZATION_RETRY_PROMPT}
def build_budget_exhausted_finalization_message() -> dict[str, str]:
"""Prompt the model for a no-tools final response after budget exhaustion."""
return {"role": "user", "content": BUDGET_EXHAUSTED_FINALIZATION_PROMPT}
def build_length_recovery_message() -> dict[str, str]:
"""Prompt the model to continue after hitting output token limit."""
return {"role": "user", "content": LENGTH_RECOVERY_PROMPT}