Skip to main content
This guide provides comprehensive instructions for migrating your LarAgent project from v0.8 to v1.0. Follow the sections in order, starting with the most critical changes that affect the public API.

Critical Changes

These changes will break your code if not addressed. Review and update these first before upgrading.

Message Factory API Changes

The Message class is now a pure factory class with only typed static factory methods. The following methods have been removed:
1

Find Message::create() occurrences

Run this command to locate all usages in your codebase:
2

Replace with typed factory methods

Update your code to use the new typed factory methods:
3

Replace Message::fromArray()

Find occurrences:
4

Replace Message::fromJSON()

Find occurrences:

Available Factory Methods


ToolResultMessage Constructor Signature

The ToolResultMessage constructor signature has changed completely. You must provide $toolName for Gemini driver compatibility.
The constructor now accepts $toolName as an optional third parameter.
1

Find ToolResultMessage usages

2

Update constructor calls


ToolCallMessage Constructor Signature

The ToolCallMessage constructor no longer accepts the $message array parameter.
1

Find ToolCallMessage usages

2

Update constructor calls


ChatHistory Interface Changes

If you have custom ChatHistory implementations or directly use ChatHistory methods, this section is critical.

Key Changes

  1. getMessages() now returns MessageArray instead of array
  2. Several methods have been removed from the interface
  3. New truncation system replaces manual context window management

Removed Methods

1

Update getMessages() usage

2

Replace context window methods

3

Replace chat key management

Use the new Context facade or Agent methods:
The Context facade provides powerful filtering and iteration capabilities. See the New Features section for more details.

Agent Class Changes

Removed Properties and Methods

Removed Properties

Removed Methods

Renamed Methods

The old method names still work but are deprecated. Update to the new names when possible.

Available Methods

These methods from HasContext trait are available:
1

Update method calls

2

Remove includeModelInChatSessionId usage

3

Replace contextWindowSize with truncationThreshold


New Context System

LarAgent v1.0 introduces a new Context System that manages all storages (chat history, state, identities) through a unified interface.

New Properties

Configure storage drivers in your Agent class:

Config Property Renames

Update your published config file (config/laragent.php):
Alternatively, republish the config file:

Driver and Configuration Changes

DriverConfig DTO for Custom Drivers

This section only affects custom LLM driver implementations.
Driver configurations now use DriverConfig DTO internally instead of plain arrays.
1

Update constructor signature

2

Update config access

3

Update sendMessage signatures


Custom ChatHistory Implementations

This section only affects custom ChatHistory classes.
Chat history classes should now extend ChatHistoryStorage instead of the old ChatHistory abstract class.
1

Update your custom history class

2

Create custom StorageDriver (if needed)

If you need custom storage logic, create a custom StorageDriver:

New Features

These features are new in v1.0 and don’t require migration. Consider using them to enhance your agents.

Message IDs and Timestamps

All messages now have unique IDs and timestamps:

Message Extras

Store driver-specific or custom fields:

Usage Tracking

Enable automatic token usage tracking:

Truncation Strategies

Automatic conversation truncation when context exceeds threshold:

Context Facade

New facade for managing storage outside of agents:

DataModel Classes

Use DataModels for structured output:

Quick Migration Checklist

Use this checklist to ensure you’ve covered all migration steps.
  • Replace all Message::create() with typed factory methods
  • Replace all Message::fromArray() with specific message class fromArray()
  • Update ToolResultMessage constructor calls to include $toolName
  • Update ToolCallMessage constructor calls to remove $message parameter
  • Replace $contextWindowSize with $truncationThreshold
  • Remove $saveChatKeys (now automatic via Context system)
  • Remove $includeModelInChatSessionId and related method calls
  • Update provider config default_context_windowdefault_truncation_threshold
  • Update provider config chat_historyhistory
  • If custom drivers: update constructor to call parent::__construct($settings)
  • If custom chat history: refactor to use ChatHistoryStorage with custom driver

Getting Help

If you encounter issues during migration:

GitHub Issues

Open an issue for bugs or migration problems

Discord Community

Get help from the community