Metadata-Version: 2.4
Name: redlineai-sdk
Version: 0.2.6
Summary: Run your own agents inside Redline AI experiments — from your repo, with `redline dev`.
Author: Redline AI
License: MIT License
        
        Copyright (c) 2026 Redline AI
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://tryredlineai.co
Project-URL: Documentation, https://tryredlineai.co/docs/agents/your-agent
Project-URL: Source, https://github.com/hritvikgupta/redlineai
Project-URL: Issues, https://github.com/hritvikgupta/redlineai/issues
Keywords: agents,evaluation,benchmark,llm,ai,pydantic-ai,langchain,opentelemetry
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Testing
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: otel
Requires-Dist: opentelemetry-sdk>=1.20; extra == "otel"
Provides-Extra: mcp
Requires-Dist: mcp>=1.9; extra == "mcp"
Dynamic: license-file

# redlineai-sdk

Run **your own agent** inside a [Redline](https://tryredlineai.co) experiment — from your
repository, on your machine, against the same tasks and rubrics as the agents in
the catalog.

Your agent does not move. It stays where it is, keeps its own dependencies and
its own model keys, and Redline sends it work.

## Install

```sh
pip install redlineai-sdk
redline init
```

`init` writes `agents.py` — one file, holding one TODO.

## Wrap what you already wrote

```python
from redline import agent
from myapp.agent import your_agent      # ← your existing code, unchanged


@agent(id="my-agent", name="My Agent", description="Describe what it is good at.")
def run(task, ctx):
    ctx.thinking("Working out what the task needs…")
    return your_agent(task.prompt)      # ← the one line that is yours
```

Then:

```sh
export REDLINE_API_KEY=rl_…            # Agents page → Connect your agent
redline dev
```

That registers the agent with your project and holds a connection open. It now
appears on the Agents page, can be selected in an experiment, and runs on your
machine when one is launched.

There is no endpoint to expose and nothing deployed to us — `redline dev`
connects **outbound** and pulls its work, so it runs from a laptop behind NAT.

## Telemetry you do not have to write

```sh
pip install "redlineai-sdk[otel]"
```

Any framework that speaks OpenTelemetry — Pydantic AI, LangChain's
instrumentation, anything on the global tracer — has its LLM and tool spans land
in the run's transcript by itself. `ctx.thinking(...)` is there for what the
spans do not say.

## What an experiment gives your agent

An experiment can attach MCP servers, skills, CLIs and repositories. Those
arrive as **real tools**, not as prose in the prompt:

```sh
pip install "redlineai-sdk[mcp]"
```

```python
import asyncio
from redline import agent, redline_tools


@agent(id="my-agent", name="My Agent")
def run(task, ctx):
    attached = asyncio.run(redline_tools(task))   # MCP tools + machine_run
    return your_agent(task.prompt, tools=attached.as_openai_schema())
```

`AttachedTools` also hands them over ready-shaped: `for_pydantic_ai()` returns
Pydantic AI `Tool`s, `for_langchain()` returns `StructuredTool`s.

**If your agent has its own tool registry** — which most do past the prototype
stage — there is a framework-free pair. `as_openai_schema()` is what to
advertise to the model, and `call()` is what to do when it picks one:

```python
attached = asyncio.run(redline_tools(task))

my_tools += attached.as_openai_schema()               # advertise
result = asyncio.run(attached.call(name, arguments))  # execute
```

Nothing there knows anything about your framework, and it is the whole
integration for a hand-rolled loop.

If your agent uses Pydantic AI or LangChain, you can skip even that. `redline
dev` patches `pydantic_ai.Agent`, `langgraph.prebuilt.create_react_agent` and
`langchain.agents.create_tool_calling_agent` as they are constructed, so the
experiment's tools are already on your agent without a line of yours changing.

### The machine

`machine_run` is there in every run — not only the ones that attached
something. Your agent runs on your laptop; this is a shell on the project's
Linux machine, in a directory of the run's own. Attach a repository and it is
already cloned there; attach nothing and you still have a computer, which is
what an agent needs the moment a task says "write a file".

```python
attached = asyncio.run(redline_tools(task))
# → machine_run, plus a tool per attached MCP server
```

The machine starts when you first call the tool and never before, so a run that
does not use it costs nothing.

## Your repo's environment

`redline dev` is a second entry point into your app, and your real one almost
always loads a `.env` first — so this one does too, searching the root and one
level down. Shell variables always win. `REDLINE_ENV_FILES=server/.env` takes
exact control.

## Commands

| | |
|---|---|
| `redline init` | write a starter `agents.py` |
| `redline dev` | register your agents and take work |

| | |
|---|---|
| `REDLINE_API_KEY` | runner key, `rl_…`, from the Agents page |
| `REDLINE_URL` | your Redline; defaults to `http://localhost:8790` |

## Where agents are found

`agents.py`, or every `*.py` in an `agents/` folder. Not `redline.py` — a file
by that name in your working directory shadows this package on `sys.path`, and
the import error it produces blames the wrong thing entirely.

## Names

| | |
|---|---|
| install | `pip install redlineai-sdk` |
| import | `from redline import agent` |
| npm | `@redlineai/sdk` |

The npm package is scoped and PyPI has no scopes, so `@redlineai/sdk` cannot
exist here — `redlineai-sdk` is the same name with the slash flattened. The
import stays `redline`, which is what you type a hundred times more often than
the install line.

`pip install redline-sdk` also works; it is a shim that installs this.

## Docs

<https://tryredlineai.co/docs/agents/your-agent>

MIT.
