wiki/poweron/spec-workflow-architecture.md
2025-09-23 22:48:00 +02:00

69 lines
3.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Title: PlanActObserveRefine Workflow Architecture (PowerOn)
Overview
- Objective: Replace bulk “task plan → full action plan → execute later” with a compact iterative loop: plan (select one action) → act (execute with minimal params) → observe (summarize results) → refine (decide next step or stop).
- Benefits: Lower token usage, higher accuracy via tight feedback, less overplanning, clearer document routing, and better failure recovery.
Core Loop
1) Plan (Select)
- Input: objective, success criteria, tiny tool catalog (names + parameter names only), minimal available documents/connections, and short rules.
- Output (JSON): {"action": {"method": "<method>", "name": "<action>"}}
- Constraints: exactly one action per iteration.
2) Act (Specify + Execute)
- Input: selected action name from Plan.
- Model returns only required parameters for that action: {"parameters": {...}}.
- Host validates and applies in-code defaults (user language, depth, recency) then executes.
3) Observe (Summarize Results)
- Host returns a compact observation object, not raw payloads:
{
"success": true|false,
"resultLabel": "roundX_taskY_actionZ_label",
"documentsCount": N,
"previews": [{"name":"..","mime":"..","snippet":".."}],
"notes": ["short fact"],
}
- For web results, include per-URL relevance, key points, entities if available.
4) Refine (Decide Next or Stop)
- Model decides: stop with final answer or propose next single action (return to Plan).
- Stop criteria: all success_criteria met; or no further actions can improve score; or max steps reached.
Minimal Tool Catalog (names + param names only)
- web.search(query,maxResults,searchDepth,timeRange,topic,includeDomains,excludeDomains,language,includeAnswer,includeRawContent)
- web.scrape(query,maxResults,searchDepth,timeRange,topic,includeDomains,excludeDomains,language,includeAnswer,includeRawContent,extractDepth,format)
- web.crawl(documentList,extractDepth,format)
- ai.process(documentList,aiPrompt,processingMode,includeMetadata,customInstructions,expectedDocumentFormats)
- document.extract(documentList,aiPrompt)
- document.generateReport(documentList,title)
Business Rules (Prompt-Level, ≤7 lines)
- Pick exactly one action per step; then specify only its parameters.
- Derive parameters from objective + criteria; use user language; add recency only if freshness is implied.
- Only request machine-readable formats when explicitly required; otherwise narrative text/markdown.
- Keep parameters minimal; avoid connector-specific knobs; chain outputs so next step is consumable.
- Stop when criteria are met; otherwise iterate with a new single action.
Defaults (Code-Level, not Prompt)
- Language default from user profile; depth advanced for analysis, basic for lookups.
- Time window only when criteria imply freshness.
- ai.process defaults to markdown narrative unless expectedDocumentFormats explicitly requests structured data.
State and Routing
- Workflow context tracks (currentRound, currentTask, currentAction).
- Each action execution attaches documents with a deterministic resultLabel: round{r}_task{t}_action{a}_{label}.
- Observation objects reference only labels and previews to limit prompt size.
Failure Handling
- After observe, a lightweight review step classifies: success | retry | failed, with improvements.
- Retry increments a small counter; criteria progress tracked across attempts.
Security & Limits
- Allowed methods per task type; deny-list for risky methods.
- Max steps per task; token budget guard; truncate observations to safe size.
Final Output
- When stopping, model produces a concise final message and, if applicable, invokes a last formatting action (e.g., ai.process → report md) before ending.