# Agent Management

Create New Agent

```bash
# Interactive mode
composabl agent new

# With all options
composabl agent new \
  --name my-agent \
  --type local \
  --location ./agents/

# Agent types:
# - local: For local development
# - docker: For Docker deployment
# - composabl: For cloud deployment
```

#### Generated Agent Structure

```python
# agent.py
import os
from composabl import Agent, Skill, Trainer, MaintainGoal, Sensor

# Accept EULA and set license
os.environ["COMPOSABL_EULA_AGREED"] = "1"
# os.environ["AMESA_LICENSE"] = "YOUR_LICENSE_KEY"

class BalanceTeacher(MaintainGoal):
    def __init__(self, *args, **kwargs):
        super().__init__(
            "pole_theta", 
            "Maintain pole upright", 
            target=0, 
            stop_distance=0.418
        )
    
    async def compute_action_mask(self, transformed_sensors, action):
        return None
    
    async def transform_sensors(self, sensors, action):
        return sensors
    
    async def transform_action(self, transformed_sensors, action):
        return action
    
    async def filtered_sensor_space(self):
        return ["cart_pos", "cart_vel", "pole_theta", "pole_alpha"]

def main():
    # Create agent
    a = Agent()
    
    # Add sensors
    a.add_sensors([
        Sensor("cart_pos", "Cart Position", lambda obs: obs[0]),
        Sensor("cart_vel", "Cart Velocity", lambda obs: obs[1]),
        Sensor("pole_theta", "Pole Angle", lambda obs: obs[2]),
        Sensor("pole_alpha", "Pole Angular Velocity", lambda obs: obs[3])
    ])
    
    # Add skill
    skill = Skill("pole-balance", BalanceTeacher)
    a.add_skill(skill)
    
    # Configure trainer
    r = Trainer({
        "target": {"local": {"address": "localhost:1337"}},
        "post_processing": {
            "record": {
                "is_enabled": True,
                "file_path": "/tmp/composabl/recordings"
            }
        }
    })
    
    # Train
    r.train(a, train_cycles=5)
    r.close()

if __name__ == "__main__":
    main()
```

#### Train Agent

```bash
# Train Python agent file
composabl agent train ./agents/my-agent/agent.py

# Train with JSON configuration
composabl agent train --agent-json ./configs/agent.json
```

#### Visualize Agent

```bash
# Visualize agent structure from JSON
composabl agent visualize ./agent.json
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.amesa.com/reference/cli-reference/agent-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
