# Quick Start

## Quick Start with Claude Code Max Plan (No API Key)

The fastest way to run an agent -- uses your Claude Code Max Plan subscription directly, no API key needed.

**1. YAML config (`agent-config.yml`)**

```yaml
agentId: my-agent
name: my-agent
type: react

model:
  provider: claude-code
  name: sonnet
  temperature: 0.3
  maxTokens: 4096

systemPrompt: |
  You are a helpful assistant.
```

**2. Run via PaaS CLI**

```bash
# Create and chat
python3 -m agentpaas agent create --name my-agent --config agent-config.yml
python3 -m agentpaas chat my-agent
```

**3. Run directly**

```bash
python3 agentexample/agent67/run.py --claude
```

The `--claude` flag forces the Claude Code backend (`claude -p --resume`), bypassing any API-key provider in the config. Session persistence via `--resume` means the LLM retains full conversation history, eliminating hallucination from lost context.

> `--strict-mcp-config` is passed automatically to isolate MCP tools -- the agent only sees tools declared in your YAML, not host-level MCP servers (Vercel, Gmail, etc.).

---

## Simple Agent

```python
from lambdagent import Lam

agent = Lam("summarizer", "Summarize the input concisely.")
result = agent("A very long article about quantum computing...")
```

## Pipeline (Compose)

```python
extract = Lam("extract", "Extract key facts.")
analyze = Lam("analyze", "Analyze the facts.")
report = Lam("report", "Write a report.")

pipeline = extract >> analyze >> report
result = pipeline("Raw data...")
```

## ReAct Agent (Y Combinator)

```python
from lambdagent import Lam, Loop, Tool

search = Tool("search", lambda q: web_search(q))

agent = Loop(
    body=Lam("think", "Reason about the question. Use tools if needed."),
    condition=lambda r, s: "DONE" in str(r) or s >= 9,
    max_steps=10,
)
```

## From YAML (API-Key Providers)

For providers that require an API key (Anthropic, OpenAI, DashScope, etc.):

```yaml
model:
  provider: anthropic          # or openai, dashscope, deepseek, moonshot, ollama
  name: claude-sonnet-4-20250514
  temperature: 0.3
```

```python
from lambdagent import from_config

agent = from_config("agent-config.yml")
result = agent("Your question here")
```

Set the corresponding environment variable (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `DASHSCOPE_API_KEY`, etc.) before running.

## Engine Selection

lambdagent supports dual execution engines. Add `runtime.engine` to your YAML to switch:

```yaml
runtime:
  engine: cek    # recursive (default) | cek | adaptive
```

The `cek` engine provides step-level cost monitoring, pause/resume, and loop detection for complex agents.

## One-Sentence Builder

```bash
python nl2agent.py "Build a research assistant with search tools" -t "Research AI agents"
```
