Support Anthropic conversation logging and retries
Tests / Test apps.device-host-agent.tests.test_mcp_token.test_load_or_create_concurrent_calls_do_not_corrupt failed

This commit is contained in:
showtan001
2026-08-30 22:29:19 +08:00
parent 44e1a6651a
commit 5458f3b8a4
4 changed files with 113 additions and 14 deletions
+6
View File
@@ -43,6 +43,12 @@ class AIPlanner(Planner):
history_summary=_history_summary(world),
device_platform=context.device_platform,
)
if context.step_results and not context.step_results[-1].success:
user_prompt += (
"\n\nThe previous tool call failed. Diagnose the failure and choose a "
"corrected action or finish the task if it cannot proceed.\n"
f"Previous failure: {context.step_results[-1].error or 'unknown error'}"
)
decision = self.client.decide(
system_prompt=PLANNER_SYSTEM_PROMPT,
user_prompt=user_prompt,
+12 -7
View File
@@ -187,13 +187,18 @@ class TaskRunner:
"failed",
result.error or "step failed",
)
self._update_task(
task,
status="failed",
completed=True,
failure_reason=result.error or "step failed",
)
return task
# AI planners can use the structured failure feedback to
# correct malformed arguments or choose another action.
# Deterministic planners retain their fail-fast behavior.
if self.planner.__class__.__name__ != "AIPlanner":
self._update_task(
task,
status="failed",
completed=True,
failure_reason=result.error or "step failed",
)
return task
break
self._emit_step_progress(
len(context.step_results),