Files
page-agent/packages/llms
dependabot[bot] d05b43cf50 chore(deps): bump the production-dependencies group across 1 directory with 3 updates
Bumps the production-dependencies group with 3 updates in the / directory: [zod](https://github.com/colinhacks/zod), [motion](https://github.com/motiondivision/motion) and [simple-icons](https://github.com/simple-icons/simple-icons).


Updates `zod` from 4.2.1 to 4.3.5
- [Release notes](https://github.com/colinhacks/zod/releases)
- [Commits](https://github.com/colinhacks/zod/compare/v4.2.1...v4.3.5)

Updates `motion` from 12.23.26 to 12.24.0
- [Changelog](https://github.com/motiondivision/motion/blob/main/CHANGELOG.md)
- [Commits](https://github.com/motiondivision/motion/compare/v12.23.26...v12.24.0)

Updates `simple-icons` from 16.2.0 to 16.4.0
- [Release notes](https://github.com/simple-icons/simple-icons/releases)
- [Commits](https://github.com/simple-icons/simple-icons/compare/16.2.0...16.4.0)

---
updated-dependencies:
- dependency-name: zod
  dependency-version: 4.3.5
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: production-dependencies
- dependency-name: motion
  dependency-version: 12.24.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: production-dependencies
- dependency-name: simple-icons
  dependency-version: 16.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: production-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-05 19:37:33 +00:00
..
2025-12-24 19:28:59 +08:00
2025-12-22 16:29:19 +08:00

@page-agent/llms

LLM client with a reflection-before-action mental model for page-agent.

Why This Package Exists

The LLM module and the agent logic are inherently coupled. This package exists not to decouple them, but to define the interface contract between the LLM and the agent.

The core abstraction is the MacroToolInput — a structured output format that forces the model to reflect before acting.

The Reflection-Before-Action Model

Every tool call must first output its reasoning state before the actual action:

interface MacroToolInput {
  // Reflection (mandatory before any action)
  evaluation_previous_goal?: string  // How well did the previous action work?
  memory?: string                     // Key information to remember
  next_goal?: string                  // What to accomplish next

  // Action (the actual operation)
  action: Record<string, any>
}

This design ensures that:

  1. The model evaluates its previous action before deciding the next step
  2. Working memory is explicitly maintained across conversation turns
  3. Goals are clearly stated, making the agent's reasoning transparent and debuggable

Key Components

Export Description
LLM Main LLM client class with retry logic
MacroToolInput The reflection-before-action input schema
AgentBrain Agent's thinking state (eval, memory, goal)
LLMConfig Configuration for LLM connection
parseLLMConfig Parse and apply defaults to config