agent.rs — Core Agent Lifecycle

The Agent struct is the heart of Oxyde. It manages emotion, memory, goal selection, and LLM inference.

🔧 Key Structs & Methods

pub struct Agent {
    pub id: String,
    pub memory: MemoryManager,
    pub emotion: EmotionState,
    pub goals: GoalManager,
    pub llm: Box<dyn LLMProvider>,
}

🌀 Lifecycle Methods

  • fn receive_input(&mut self, input: &str) -> AgentResponse

    • Main entry point for user/player dialogue

    • Updates memory, emotion, goals, and triggers inference

  • fn tick(&mut self)

    • Called every frame or interaction cycle

    • Can decay emotions or reprioritize goals

  • fn apply_emotion_delta(&mut self, delta: EmotionDelta)

    • Adjusts the current emotional state

🗣️ Inference Path

let response = agent.receive_input("What's down that tunnel?");
  • This will:

    1. Recall relevant memories

    2. Construct a prompt

    3. Route the prompt via llm_service

    4. Parse response and update memory/emotion accordingly


🔁 Trait Example

trait AgentInterface {
    fn receive_input(&self, input: &str) -> AgentResponse;
    fn tick(&mut self);
}

Used by CLI demos and future multiplayer agent servers.