Files
q792602257 a5aeb8889c
Tests / Test failed: 2, passed: 849
feat(runtime): add planner reflection history with rationale and thinking
- ToolCallDecision captures thinking blocks and pre-tool text output
- AnthropicToolCallingClient supports optional extended thinking (budget_tokens + beta header)
- PlannedStep carries rationale and thinking from each LLM decision
- WorldEvent replaces scene_summary with rationale/thinking/page fields (backward-compatible)
- AI planner system prompt instructs reflection before each tool call
- _history_summary() emits compact {page, rationale, action, success} dicts
- Cloud DB migration 0011 adds nullable rationale/thinking columns to planner_decision_log
- OpenAI client extracts reasoning_content into thinking field
2026-07-15 12:43:22 +08:00

40 lines
3.1 KiB
Markdown

## MODIFIED Requirements
### Requirement: Cloud Console displays a task's full LLM interaction history
Cloud Console SHALL provide a view, for a given task, listing each persisted planner decision in step order, including its full prompt, resulting decision, and — when available — the AI's rationale (pre-tool text reflection) and thinking (extended thinking block), sourced from the Cloud Control Plane's persisted planner-decision log.
#### Scenario: Task has persisted planner decisions with rationale
- **WHEN** an operator opens the LLM interaction history view for a task that has one or more persisted planner decisions with non-null rationale
- **THEN** Cloud Console shows each decision in step order with its prompt, resulting tool call, and rationale text
#### Scenario: Task has persisted planner decisions with thinking
- **WHEN** an operator opens the LLM interaction history view for a task whose planner decisions include a non-null thinking field
- **THEN** Cloud Console shows the thinking content alongside the prompt and tool call for that step
#### Scenario: Task has persisted planner decisions without rationale or thinking
- **WHEN** an operator opens the LLM interaction history view for a task whose decisions have null rationale and null thinking
- **THEN** Cloud Console shows each decision without those fields, without error or placeholder text
#### Scenario: Task's Host used direct-to-provider transport
- **WHEN** an operator opens the LLM interaction history view for a task whose Host used direct-to-provider transport
- **THEN** Cloud Console indicates that no LLM interaction history is available because the Host does not report it, rather than showing an empty history with no explanation
### Requirement: Cloud Control Plane persists rationale and thinking in the planner decision log
The Cloud Control Plane's planner-decision log SHALL store the AI's rationale and thinking fields alongside the existing prompt and tool-call fields for each persisted decision. Both fields SHALL be nullable; absence of either field SHALL NOT prevent a decision record from being stored or queried.
#### Scenario: Decision record includes rationale
- **WHEN** the Host Agent reports a planner decision with a non-null rationale
- **THEN** the persisted `planner_decision_log` row stores that rationale text in the `rationale` column
#### Scenario: Decision record includes thinking
- **WHEN** the Host Agent reports a planner decision with a non-null thinking block
- **THEN** the persisted `planner_decision_log` row stores that thinking text in the `thinking` column
#### Scenario: Decision record has no rationale or thinking
- **WHEN** the Host Agent reports a planner decision with null rationale and null thinking (e.g., cloud-proxy transport where these are not surfaced)
- **THEN** the persisted row stores NULL for both columns without error
#### Scenario: Existing decision records without rationale or thinking remain readable
- **WHEN** the system queries a `planner_decision_log` row created before this migration
- **THEN** both `rationale` and `thinking` read as NULL, and the row is returned normally