# Agent Proxy

> |

- **Type:** Skill
- **Install:** `agentstack add skill-yechao-zhang-red-team-agent-skills-agent-proxy`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [yechao-zhang](https://agentstack.voostack.com/s/yechao-zhang)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [yechao-zhang](https://github.com/yechao-zhang)
- **Source:** https://github.com/yechao-zhang/red-team-agent-skills/tree/main/.claude/skills/agent-proxy

## Install

```sh
agentstack add skill-yechao-zhang-red-team-agent-skills-agent-proxy
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Agent Proxy Skill

**Universal API Gateway**: Given a URL to any AI agent API, this skill auto-discovers the protocol (REST, WebSocket, Gradio) and conducts conversations.

**Critical**: This works WITHOUT needing:
- ❌ Access to the target agent's source code
- ❌ The target agent's dependencies installed
- ❌ Knowledge of the target agent's implementation

You only need the agent's **API URL**.

**Note on Web UIs**: For browser-based agents (ChatGPT, Gemini, etc.), please use the **`dev-browser`** skill or Red Team's **BrowserTransport** instead. This skill is strictly for APIs.

## Installation

```bash
# Install agent-proxy dependencies
cd ~/.claude/skills/agent-proxy
pip install -r requirements.txt
```

## Workflow

```
User provides URL → Auto-detect Protocol (API/WS) → Create Protocol Adapter → Communicate
```

## Quick Start

```python
from agent_proxy import AgentProxy

# Just give it a URL - it figures out the protocol automatically
proxy = AgentProxy()
proxy.connect("http://localhost:8080/v1/chat/completions")  # API Endpoint

# Now Claude Code speaks AS the user
response = proxy.say("Hello, I need help with Python")
response = proxy.say("Can you show me an example?")

# Get full conversation
print(proxy.history)
proxy.close()
```

## Supported Agent Types (Auto-detected)

The skill auto-detects these communication patterns:

| URL Pattern | Detection | Method |
|-------------|-----------|--------|
| `*/v1/chat/completions` | OpenAI-compatible API | POST JSON |
| `*/v1/messages` | Anthropic API | POST JSON |
| `*/api/chat`, `*/api/generate` | Ollama/LLM APIs | POST JSON |
| `*/api/sessions`, `*/api/ws` | REST+WebSocket API | REST + WebSocket |
| `ws://`, `wss://` | WebSocket | WS messages |
| Gradio apps | Gradio API | gradio_client |
| Custom endpoints | Probe & detect | Auto-detect |

## Usage Modes

### Mode 1: Auto-Detect (Recommended)

```python
proxy = AgentProxy()
proxy.connect("https://api.some-agent.com/v1/chat")  # Auto-detects protocol
response = proxy.say("Hello!")
```

### Mode 2: With Hints

```python
proxy = AgentProxy()
proxy.connect("https://api.example.com/v1/chat", hints={
    "type": "openai",  # Force OpenAI format
    "api_key": "sk-...",
    "model": "gpt-4"
})
```

## Detection Process

When given a URL, the skill:

1. **Probe the endpoint**
   - Check response headers (Content-Type, Server)
   - Look for API documentation endpoints (/docs, /openapi.json)
   - Detect framework signatures (Gradio, Streamlit, FastAPI)

2. **Identify protocol**
   - REST API → detect request/response format
   - WebSocket → establish WS connection

3. **Create appropriate adapter**
   - Configure authentication if needed
   - Set up message format
   - Handle streaming responses

## For Claude Code Usage

When the user gives you an agent URL:

1. Run `scripts/detect_agent.py ` to analyze it
2. Use the detected config with `AgentProxy`
3. Conduct the conversation as the user

Example workflow:
```bash
# Step 1: Detect
python scripts/detect_agent.py "http://localhost:8080"

# Output: Detected OpenAI-compatible API at /v1/chat/completions
# Config: {"type": "openai_api", "endpoint": "...", "model": "..."}

# Step 2: Use
python scripts/talk.py --url "http://localhost:8080" --message "Hello!"
```

## Handling Authentication

If the agent requires authentication:

```python
proxy.connect("https://api.example.com/chat", hints={
    "auth": {
        "type": "bearer",  # or "api_key", "basic", "header"
        "token": "your-token"
    }
})
```

## Output

All conversations are logged:

```json
{
  "agent_url": "http://localhost:8080",
  "detected_type": "openai_api",
  "turns": [
    {"role": "user", "content": "Hello"},
    {"role": "assistant", "content": "Hi! How can I help?"}
  ]
}
```

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [yechao-zhang](https://github.com/yechao-zhang)
- **Source:** [yechao-zhang/red-team-agent-skills](https://github.com/yechao-zhang/red-team-agent-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** yes
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-yechao-zhang-red-team-agent-skills-agent-proxy
- Seller: https://agentstack.voostack.com/s/yechao-zhang
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
