LLMCore class
Orchestrates all LLM interactions for the agent.
Usage
final core = LLMCore(
provider: HttpLLMProvider(apiKey: '...', model: 'gpt-4o'),
memory: store,
);
final decision = await core.reason(context);
// decision.type == AgentDecisionType.useTool
// decision.toolName == 'search_web'
Response schema the LLM must follow
The system prompt instructs the LLM to return one of:
{"action":"use_tool","tool":"<name>","input":{...},"thought":"..."}
{"action":"think","thought":"..."}
{"action":"complete","reason":"..."}
{"action":"replan","reason":"..."}
{"action":"error","message":"..."}
Constructors
- LLMCore({required LLMProvider provider, required AgentMemoryStore memory, LLMCoreConfig? config, ConsciousnessLogger? logger})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- provider → LLMProvider
-
Exposes the underlying LLMProvider for direct use by subsystems
(e.g. PlanningEngine uses it to make planning-specific requests).
no setter
- reasoningCalls → int
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- totalCompletionTokens → int
-
no setter
- totalPromptTokens → int
-
no setter
Methods
-
buildPrompt(
AgentContext context) → List< LLMMessage> -
Builds a complete prompt as a list of LLMMessages from
context. -
compressContext(
String text, {int maxChars = 2000}) → String -
Compresses
textto at mostmaxCharscharacters by truncating the middle section and inserting an ellipsis. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reason(
AgentContext context) → Future< AgentDecision> - Core reasoning call.
-
summariseMemory(
AgentContext context) → String - Summarises the agent's memory into a short paragraph.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited