Back to Blog

Anatomy of an Agent Pt. 2: Technical Architecture

Anatomy of an Agent Pt. 2: Technical Architecture

Dec 11, 2024

DeFi’s complexity creates a paradox: manually monitoring opportunities and managing risk across protocols requires constant vigilance, yet delegating these decisions typically means giving up control. Giza Agents resolve this dichotomy through an architecture that makes autonomous decision-making intrinsically safe, controlled, and transparent — where the same code that enables automated execution also enforces its boundaries. In part 1 of our series, “Anatomy of an Agent”, we introduced Giza Agents and provided a broad overview of their architecture and affordances. This follow-up piece presents a comprehensive deep dive into key components of the tech stack that power these capabilities and make Agents secure and seamless for users.


The Foundation: Smart Accounts

Traditional blockchain accounts (EOAs) tightly couple asset custody with transaction signing — the same account that owns funds must sign every transaction. Smart accounts (following ERC-4337) fundamentally change this model by separating asset custody from transaction authorization through programmable validation logic. This enables secure delegation of transaction execution while maintaining non-custodial control.

When a user engages with a Giza Agent, the system creates a smart account linked to the user’s own EOA. This smart account, fully owned and controlled by the user, is capable of holding funds and executing complex transactions on their behalf. The smart account’s operations are governed by predefined rules and permissions, ensuring that it can autonomously interact with various DeFi protocols while maintaining strict security boundaries.

Enabling Safe Autonomy: Session Keys

Session keys empower Giza Agents with secure autonomy by granting limited, predefined permissions to act on behalf of users without requiring constant approval for each action.

When an Agent is activated, the system generates a set of session keys with granularly scoped permissions. These permissions might include swapping tokens, providing liquidity to specific pools, or interacting with designated smart contracts. Session keys are configurable to enforce strict limitations on an Agent, such as restricting actions, limiting transaction values, or ending the session after a set time period or trigger event.



The Decision Maker: Agent Core

The Agent Core represents the central decision-making component of the Agent, transforming market data and user preferences into actionable blockchain transactions. This component embodies the Agent’s intelligence by continuously evaluating market conditions, protocol states, and user parameters to identify and execute optimal strategies.

The Agent Core implements a multi-stage decision process.

The first stage is data aggregation, where information is continually sourced from on-chain data, protocol states, and market conditions. This data undergoes preliminary processing to normalize formats and filter out noise, ensuring that decisions are based on clean, reliable information.

The second stage is strategic evaluation, where the Agent Core combines traditional financial algorithms with artificial intelligence to identify opportunities that align with the user’s objectives. This hybrid approach allows the system to leverage both established financial principles and advanced pattern recognition capabilities. One notable example is the APR forecasting system, which analyzes historical data and market conditions to predict yield opportunities over a seven-day horizon. These predictions help the Agent optimize position timing and protocol selection.

The decision-making process considers multiple factors simultaneously: potential returns, associated risks, transaction costs, and the current state of the user’s positions. The Agent Core can weigh these factors differently based on user preferences and market conditions. It also learns from the outcomes of its decisions, allowing it to adapt and improve its strategies over time.

In the final stage, the Agent Core translates high-level strategic decisions into concrete action plans. These plans specify exact transaction parameters, including optimal timing, size, and routing. Safety checks are implemented at this stage to verify that planned actions comply with user-defined constraints and risk parameters.

Protocol Integration Module

The Protocol Integration module serves as the Agent’s interface to the DeFi ecosystem, enabling seamless interactions with external protocols through a standardized abstraction layer. This design allows the Agent to maintain consistent security and reliability standards across all integrations.

The module implements protocol-specific adapters that translate the Agent’s standardized commands into protocol-specific interactions. These adapters incorporate deep knowledge of their respective protocols, including optimal interaction patterns, common failure modes, and protocol-specific optimizations. For example, when interacting with a lending protocol, the adapter can optimize collateral ratios, manage interest rate exposure, and mitigate liquidation risks.

Protocol Integration also maintains real-time protocol state monitoring, tracking crucial metrics like liquidity depths, interest rates, and protocol health indicators. This monitoring enables the Agent to react quickly to changing conditions and avoid potential issues before they materialize. Advanced retry and recovery mechanisms ensure robust operation even when facing temporary protocol issues or network congestion.

Risk Management Module

The Risk Management module acts as the Agent’s safety system, implementing multiple layers of protection to safeguard user funds and optimize risk-adjusted returns. This module operates continuously, evaluating risks across different dimensions and adjusting strategy parameters accordingly.

At the protocol level, the module maintains a comprehensive risk-scoring system that considers factors such as smart contract security, protocol governance risks, and historical reliability. These scores are dynamically updated based on new information and market conditions. The module also implements protocol-specific risk limits that automatically adapt to changes in the protocol’s current state and the user’s exposure.

Market risk analysis is another crucial component. Here, the module evaluates factors like liquidity risk, price impact, and volatility to prevent the Agent from taking positions that could be difficult to exit or might face substantial slippage. The module also implements sophisticated position-sizing algorithms that consider cross-protocol correlations and systemic risks.

The Risk Management module maintains a hierarchical system of circuit breakers that can automatically pause or modify Agent operations when risk thresholds are breached. These circuit breakers operate at multiple levels, from individual transaction checks to system-wide risk assessments, providing comprehensive protection against both localized and systemic risks.

Accounting Module

The Accounting module functions as the Agent’s financial record keeper, maintaining a detailed and accurate representation of the user’s positions across multiple chains and protocols. This module goes beyond simple balance tracking to provide a comprehensive financial management system.

The module implements a double-entry bookkeeping system specifically designed for DeFi operations, tracking not just token balances but also complex positions like liquidity provisions, lending positions, and derivative exposures. This system maintains perfect reconciliation across all operations, ensuring that every transaction is properly recorded and its impact on the user’s portfolio is accurately reflected.

Position tracking in the Accounting module operates across multiple dimensions. At the base level, it tracks raw token balances across different chains and protocols. Above this, it maintains real-time valuations of all positions in a common denominator (typically USD), accounting for factors like impermanent loss in liquidity positions or accrued interest in lending positions. The module also tracks historical position data, enabling detailed performance analysis and tax reporting.

The Accounting module implements sophisticated performance attribution analysis, breaking down returns into components like yield farming rewards, trading gains, and fee income. This analysis helps users understand where their returns are coming from and enables the Agent to optimize its strategies accordingly.

Integration Flow

The integration of these components creates a sophisticated yet efficient operational flow that enables the agent to execute complex strategies while maintaining security and reliability.

The process begins with constant monitoring across multiple components. The Protocol Integration module tracks on-chain opportunities, while the Risk Management module maintains updated risk assessments. The Accounting module provides real-time position data, and the Agent Core processes this information stream to identify potential actions.

When an opportunity is identified, the system initiates a multi-stage evaluation process. First, the Agent Core develops a preliminary action plan, which is then validated by the Risk Management module against current risk parameters and market conditions. The Accounting module verifies that the proposed action complies with position limits and portfolio constraints.

Once validated, the execution phase begins. The Protocol Integration module constructs the necessary transactions, optimizing parameters like gas prices and slippage tolerances. These transactions are then executed through the smart account using the appropriate session keys. Throughout execution, all components maintain active monitoring, ready to respond to any unexpected conditions.

After execution, the Accounting module updates all relevant positions and performance metrics. This updated state feeds back into the monitoring process, creating a continuous cycle of evaluation and execution that maintains optimal portfolio positioning while respecting user constraints and risk parameters.

Conclusion

The architecture of Giza Agents fundamentally changes how users interact with DeFi protocols. Through secure smart accounts and session keys, Agents can make intelligent, adaptive decisions across protocols while operating strictly within user-defined boundaries. Specialized modules for risk management, accounting, and protocol integration enable complex strategies without requiring constant monitoring or technical expertise from users.

As DeFi continues to grow, this architecture proves that autonomous systems can be both powerful and predictable — expanding what’s possible in decentralized finance while giving users genuine peace of mind through trust-minimized automation.

Follow us on X for all agent developments.

Xenocognitive Finance

The Agent Revolution

Enabling the swarm of next billion DeFi users.

© 2025 GIZATECH AG