Agentic Flow from User Prompt
Article text.
Agentic Flow from Intial Intent
1. Initial Entry & Flag Parsing
- Is there a * prefix? * YES: Set no_context = True. Skip intent checker. Force use_react = False. Path: Single-shot.
- NO: Proceed to Portal Pipeline.
The system decides if it needs a reasoning loop based on:
- YAML Routing: If master_routing.yml detects a multi-step intent or force_react: true.
- Simple Factual Check: Even if ReAct is possible, a small LLM checks if the query is a "simple factual" request. If so, it sets use_react = False to save resources.
- Attachments: If only attachments are present without cross-references, ReAct is often turned off.
If use_react is TRUE, the system chooses one of three:
- Mode 1: * single-shot : Prompt handling: Prefix removed; no RAG date block injection for that case; RAG folders can be cleared for the sub-agent policy when no_context. Tool selection: Intent parsing is skipped, so requested_tools is empty going into the master. In run_sub_agent, if still no tools, infer_tools_from_request may propose tools from the task (unless the flow returns early, e.g. story/article LLM-only branch). Execution: spawn_sub_agent → run_sub_agent: runs allowed tools in order, RAG, or LLM answer paths as implemented there; result is returned as the run output.
- Mode 2: Classic ReAct loop (run_react_loop): Prompt handling: Question (optionally prefixed with a workflow prompt from config). Planner sees tool names + format_tools_for_planner (Purpose / Use when per tool). Tool selection: Each iteration calls _call_ollama_planner, which must return JSON with thought / action / input. action is a tool name from the allowed list or FINISH. Execution: tool_executor.run(ToolCall(...)) after _params_for_action (YAML mapping in react_tool_mapping where configured). Observations are appended to the conversation until FINISH or max steps. Final result: Text from FINISH’s input, plus optional URL footnotes from trace.
- Mode 3: Supervisor (plan → DAG or linear): Planning: decompose_task_to_plan (YAML decompose_planner_rules, compactors, normalize_plan_tools_to_registry) builds steps with optional tool per step; fixed plans for articles/browser when routing matches. DAG path: steps_to_task_graph → run_dag_workflow_with_self_correction: nodes run when artifact keys are ready; merges outputs/checkpoints. Linear path: For each step, if suggest_create_skill is set, the supervisor returns a “create a new skill” message instead of calling a tool. Otherwise spawn_sub_agent with requested_tools bound to step["tool"] or infer_tools_from_request on the step text if no tool was set. Final result: Merged output_so_far / artifacts / supervisor output (answer, approval metadata, etc.).
- Inference: If no tool is explicitly requested, infer_tools_from_request scores tools based on keywords and purpose.
- Skill Suggestion: If the supervisor identifies a required capability that doesn't exist in the registry, it triggers suggest_create_skill rather than failing, asking the user to define a new capability.