Engineering
agent-system avatar

agent-system

Implementation patterns for MERIDIAN autonomous AI agents using Claude API, including BaseAgent lifecycle, structured tool use, token budget enforcement, and cron scheduling.

Introduction

The agent-system skill provides a standardized architectural framework for developing, managing, and executing autonomous agents within the MERIDIAN investment platform. Built on top of the Anthropic Claude API, this system ensures consistent behavior for specialized agents like Sentinel, Scout, Librarian, and Strategist. It enforces a strict lifecycle pattern—TRIGGER, PREPARE, EXECUTE, PROCESS, PERSIST, and NOTIFY—ensuring that every AI interaction is traceable, cost-effective, and integrated with the underlying SQLite/Drizzle database schema. The framework is designed for developers who need to implement complex, long-running AI workflows that require reliable structured output and performance tracking.

  • Standardized BaseAgent class for uniform agent instantiation and lifecycle management.

  • Deep integration with Anthropic Claude SDK for high-performance model orchestration (Sonnet for routine tasks, Opus for complex synthesis).

  • Structured tool use implementation to force strict JSON outputs, ensuring data integrity for database persistence and analysis.

  • Automated token budget enforcement per execution to monitor costs and prevent model overruns.

  • Integrated scheduling via node-cron for automated background tasks like market news monitoring and portfolio analysis.

  • Comprehensive event logging for each agent run, capturing execution time, token usage, cost, and error status.

  • Modular prompt template management using contextual inputs derived from portfolio, news, and market data sources.

  • Utilize the BaseAgent abstract class for all new agent development to inherit built-in error handling and telemetry features.

  • When defining agent tools, strictly adhere to the defined JSON schemas to allow robust parsing and Drizzle ORM integration.

  • Monitor cost tracking through the logRun utility to maintain compliance with provider API budgets.

  • Use the provided scheduler patterns in src/app/api/cron to ensure reliable execution timing for time-sensitive agents like Sentinel or Strategist.

  • Ensure all API secrets and environment variables are properly configured for the respective Claude models before deploying new agent variants.

  • For maintenance, check the agentRuns database table via the provided API endpoints to debug failures or identify performance bottlenecks in agent logic.

Repository Stats

Stars
0
Forks
0
Open Issues
0
Language
TypeScript
Default Branch
main
Sync Status
Idle
Last Synced
May 4, 2026, 12:46 AM
View on GitHub