Documentation Index
Fetch the complete documentation index at: https://simplellmfunc.cn/llms.txt
Use this file to discover all available pages before exploring further.
Context-Centric
SimpleLLMFunc does not treat provider messages as something every component edits directly. Each LLM call is compiled into a provider-facing message list from three inputs:- Invocation configuration — docstring prompt, template parameters, tool guidance, output contract, and SelfRef snapshot.
- Base transcript — the history/current messages for this invocation.
- Runtime transcript patches — internal typed edits produced by LLM calls, tool execution, SelfRef primitives, abort handling, and compaction.
The Problem
In many agent systems, the same mutable message list is edited from everywhere:- tools append results directly;
- orchestration pushes assistant messages into the list;
- memory systems inject or rewrite context in arbitrary places;
- summarization overwrites history in place;
- abort/cancel handling leaves partially valid messages behind.
The Runtime Patch Model
SimpleLLMFunc usesContextMutation as an internal transcript patch protocol.
A mutation is not the whole context and not the user’s main API. It is a typed incremental edit to the base transcript, produced by runtime side effects and applied at a compile boundary.
| Runtime fact | Internal patch |
|---|---|
| LLM produced a final assistant message | AssistantMessageMutation |
| Tool returned text | ToolResultMutation |
| Tool returned multimodal content | MultimodalToolResultMutation |
| SelfRef compacted working context | ContextSummaryMutation |
| User aborted streaming LLM output | AssistantTruncatedMutation |
| Tool execution was cancelled | ToolCancelledMutation |
Runtime side effects do not directly mutate the live transcript. They produce typed patches, and the compile boundary applies those patches in order.This keeps tool scheduling, LLM output handling, SelfRef, compaction, and abort behavior from racing over the same mutable list.
What Mutations Are Not
Mutations are deliberately narrower than “context”. They are not:- the source of the docstring/system prompt;
- the source of template parameters;
- the source of tool schemas or tool best-practice prompts;
- the source of the initial
historypassed to@llm_chat; - the public event stream consumed by UIs;
- the primary user-facing way to customize an agent.
Why This Still Matters
Safe concurrency
Parallel tools can finish in any order. Instead of each tool directly appending to a shared message list, tools produce result patches. The runtime collects them and applies them at the next compile boundary.Controlled compaction
Context compaction is a transcript patch. It can replace stale working messages with a summary while preserving system prompt and durable experiences.Valid abort/cancel state
Abort handling must leave a structurally valid transcript.AssistantTruncatedMutation and ToolCancelledMutation centralize this repair logic instead of scattering it across the loop.
Testable internals
Patch application can be tested separately from prompt rendering and provider transport.The Compile Boundary
The compile boundary has two jobs:- Patch the base transcript with pending runtime mutations.
- Render the provider request from the patched transcript plus invocation configuration.
Practical Implication
For most users, mutations are invisible. You write functions, provide history, mount tools, consume events, and optionally use SelfRef primitives. If you are debugging framework internals, mutations explain how runtime effects become transcript edits. If you are building application code, your main surfaces are still:@llm_function/@llm_chatsignatures and docstrings;history/chat_history;- tools and event streams;
- SelfRef primitives such as
remember(...)andcompact(...).
Deep dive: Runtime Patches
See the internal mutation types and when the runtime produces them.