Skip to main content

Overview

The Microchain Agent is an autonomous trading agent built on the Microchain framework, which enables function-calling capabilities for LLMs. This agent can perform complex multi-step operations including market research, trading, and learning from experience.

Base Class: DeployableMicrochainAgentAbstract

Abstract base class for all Microchain-based agents.

Configuration Properties

SupportedModel
default:"SupportedModel.gpt_4o"
The LLM model to use for the agent
int | None
default:"50"
Maximum number of iterations per run. Set to None for unlimited iterations.
int
default:"0"
Number of past actions to import from memory on initialization
DatetimeUTC | None
default:"None"
Only import memories after this timestamp
int
default:"0"
Seconds to sleep between iterations
bool
default:"True"
Whether the agent can use the Stop function to end execution
AgentIdentifier
Unique identifier for the agent
FunctionsConfig
Configuration specifying which function categories to enable
str
The system prompt that defines the agent’s behavior

Core Components

LongTermMemoryTableHandler
Stores agent’s execution history and learnings
PromptTableHandler
Manages system prompt versioning and updates
PromptInjectHandler
Handles dynamic prompt injection for special features
Agent
The Microchain Agent instance
GoalManager | None
Optional goal management system for autonomous behavior

Methods

load

Initializes the agent’s components including memory, prompt handlers, and the Microchain agent.

run

Main execution loop for the agent. Runs iterations until stopping condition is met.

before_iteration_callback

Hook called before each iteration. Return CallbackReturn.STOP to halt execution.

after_iteration_callback

Hook called after each iteration. Return CallbackReturn.STOP to halt execution.

Production Agent: DeployableMicrochainAgent

Standard Microchain agent with full trading capabilities.

Usage

Learning Variants

Agents with “just born” system prompts that can modify their own behavior.

DeployableMicrochainModifiableSystemPromptAgent0/1/2

Agents that start with minimal knowledge and learn through experience.
FunctionsConfig
Uses JUST_BORN_SYSTEM_PROMPT_CONFIG with learning functions enabled
str
Minimal “just born” prompt allowing the agent to discover its capabilities

DeployableMicrochainModifiableSystemPromptAgent3

Llama 3.1 variant with reduced iterations.

Goal-Managed Agent

DeployableMicrochainWithGoalManagerAgent0

Agent with autonomous goal setting and evaluation.

Goal Manager Configuration

Supported Models

Function Categories

The agent can be configured with various function categories:
bool
Basic utility functions
bool
Agent self-modification capabilities
bool
API calls, code execution, web search
bool
Task scheduling and automation
bool
Memory and learning capabilities
bool
Market analysis and trading operations
bool
Fund transfer capabilities
bool
Social media integration
bool
NFT operations
bool
Balance checking and management

Building Custom Agents

Custom Function Configuration

Importing Past Memory

Custom Callbacks

Helper Functions

build_agent

Builds a Microchain agent with specified configuration.

save_agent_history

Saves agent’s execution history to long-term memory.

get_functions_summary_list

Generates a formatted list of available functions for the agent.

Advanced Features

Smart Contract Integration

Automatically generates Microchain functions from smart contract ABIs.

System Prompt Versioning

The agent automatically saves and restores system prompts:

Required API Keys

str
Required for GPT models
str
Required for Llama models
str
Required for DeepSeek and Gemini models
str
Required if search functions are enabled

Source Location