4.2 KiB
4.2 KiB
Why
The AI planner's execution history currently stores raw scene_summary (full UI tree / semantic scene JSON) per step, which bloats context tokens rapidly and conveys no semantic intent. The LLM receives a long list of "tap succeeded" entries with no understanding of why each action was taken or whether it achieved its intended effect, making it prone to repeating mistakes and unable to self-correct mid-task.
What Changes
- Planner reflection loop (method C): The system prompt is updated to require the AI to output a short text block before each tool call — first evaluating whether the previous step achieved its intended effect, then stating the intent of the current step. This reflection happens within the same LLM call (no extra API round-trip).
- Rationale capture:
ToolCallDecisioncaptures the AI's pre-tool text output (text_output) and, when extended thinking is enabled, the thinking block (thinking). Both flow throughPlannedStepintoWorldEvent. - Extended thinking support:
AnthropicToolCallingClientgains optionalthinking_budget_tokensconfig. When set, the Anthropic API is called withthinkingenabled (interleaved thinking beta); the thinking block is extracted and stored. - OpenAI reasoning capture:
OpenAIToolCallingClientextractsreasoning_contentfrom responses when present (o-series models). - Required action metadata: every device-action tool call must return a concise
purposeand observableexpected_outcome; the Runtime stores them separately from executable tool arguments so successful executions can be reused as semantically meaningful flows. - WorldEvent schema change:
scene_summaryis replaced by rationale/thinking plus the action name, executable arguments, purpose, expected outcome, andcurrent_pagefromWorldState, giving later planning and skill reuse a compact but complete action record. - History format:
_history_summary()inai_planner.pyswitches from fullWorldEvent.to_dict()to a compact{page, rationale, action, success}format. - planner_decision_log extension: The Cloud-side decision log table adds
thinkingandrationalecolumns to persist these fields alongside existing prompt/tool records.
Capabilities
New Capabilities
planner-reflection-history: AI planner captures per-step rationale (pre-tool text reflection) and optional thinking (extended thinking block), stored in execution history and surfaced in the Cloud planner decision log.
Modified Capabilities
world-model:WorldEventschema changes —scene_summarybecomes optional (backward-compat), newrationale: str | Noneandthinking: str | Nonefields added;history_summaryformat for prompt construction changes to compact representation.agent-runtime:PlannedStepgainsrationaleandthinkingfields;ToolCallDecisiongainstext_outputandthinkingfields.cloud-task-progress-visibility:planner_decision_logtable extended withthinkingandrationalecolumns.
Impact
runtime/tool_calling_client.py—ToolCallDecision,AnthropicToolCallingClient,OpenAIToolCallingClient, response parsersruntime/planner.py—PlannedStepruntime/tool_specs.py— required purpose/expected-outcome fields for device actionsruntime/ai_planner.py—AIPlanner.plan(),_history_summary()runtime/planner_prompts.py—PLANNER_SYSTEM_PROMPT,planner_user_promptruntime/planner_config.py— newthinking_budget_tokensfieldworld/models.py—WorldEventworld/model.py—_append_history()packages/cloud-platform/cloud/db_models.py—planner_decision_logtablepackages/cloud-platform/cloud/schema.py— Alembic migrationpackages/cloud-platform/cloud/internal_api/api.py—record_planner_decision()and planner decision responsepackages/cloud-platform/cloud/internal_api/models.py— planner decision transport modelsapps/device-host-agent/host_agent/cloud_planner_client.py— return reflection and action metadata from the Cloud proxyskills_learning/— retain action purpose/expected outcome in synthesized flow steps- No new external dependencies; Anthropic extended thinking uses existing SDK via beta header.