SOP Sessions
A SOPAgenticSession converts a request into a LightSOPLang plan, validates the commands, executes the dependency graph, and can replan when execution reports failures.
Plan and execution loop
flowchart TB
P[Receive prompt and prepare optional context] --> G[LLMAgent generates a LightSOPLang plan]
G --> V{Commands and topology valid?}
V -->|no| G
V -->|yes| X[Execute ready commands through the wrapped registry]
X --> C{Awaiting input or failures?}
C -->|awaiting input| W[Keep pending tool and return control to the caller]
C -->|failures within attempt limit| G
C -->|complete| R[Store plan, variables, answer, and active status]
classDef session fill:#f5f1ff,stroke:#6657b8,color:#2d246b;
classDef decision fill:#fff7e8,stroke:#b7791f,color:#633c00;
classDef outcome fill:#eefbf4,stroke:#28875d,color:#174c38;
class P,G,X session; class V,C decision; class W,R outcome;How the cycle works
- Generate and validate the planThe session prepares optional context and asks LLMAgent for a LightSOPLang plan. Every command and dependency is validated before execution, and an invalid plan returns to generation within the configured attempt limit.
- Execute ready commandsCommands run when their dependencies are satisfied. A command that needs user input is stored as
pendingTool, while recoverable failures return to bounded replanning. - Store the outcomeSuccessful execution stores the plan, variables, answer, and session status. Reserved commands provide explicit final outcomes, while
planOnlyorgeneratePlanOnlystops after plan generation.
Session memory
| Stored value | Purpose |
|---|---|
history | Prompt, planning, execution, and interruption entries used for continuation and diagnostics. |
currentPlan | The latest generated LightSOPLang source. |
lastExecution | The latest execution result, including variables and the derived final answer. |
_lastFinalAnswer | The explicit final answer emitted by the reserved command. |
lastRunFailures | Failures fed back into bounded replanning. |
pendingTool | A command paused for user input and resumed by a later prompt. |
skillsDescription | The model-visible command descriptions, including reserved runtime commands. |
commandsRegistry and planCommandsRegistry | The wrapped execution commands and the commands available while constructing the plan. |
preparationContextText and preparationContextLines | Context collected before planning when preparation is configured. |
options, maxPlanAttempts, and status | Model routing, plan-only behavior, retry bound, and lifecycle state. |
systemPrompt and baseSystemPrompt | Stable instructions used by plan generation and execution interpretation. |
Continuation boundary
newPrompt() can resume a pending tool, treat the message as a fresh instruction, or continue after interruption. replaceSkillSurface() refreshes descriptions and commands without replacing the session object. getVariables() exposes the last plan, last answer, execution variables, and status.