Skip to main content

Railtracks

Railtracks


PyPI Version Python Versions Monthly Downloads License GitHub Stars

Own the AI!
Assemble a custom agent harness in plain Python. The loop, the tools, the context, the controls, the record. All yours.

What is Railtracks?

Railtracks is a Python agent framework for building your own agents and/or harness. Every piece is an ordinary Python object you assemble yourself: a tool-calling loop, a tool surface of functions, sub-agents and MCP servers, context management, permission and budget controls, and a replayable record of every run. No YAML, no DSL, no black-box runtime.

import railtracks as rt


# Define a tool (just a function!)
def get_weather(location: str) -> str:
    """Get the current weather for a location."""
    return f"It's sunny in {location}!"


# Create an agent with tools
# agent_node returns a class, so use PascalCase
WeatherAgent = rt.agent_node(
    "Weather Assistant",
    # Alternatively, use @rt.function_node at def time
    tool_nodes=[rt.function_node(get_weather)],
    llm=rt.llm.OpenAILLM("gpt-6-luna"),
    system_message="You help users with weather information.",
)

# Run it
flow = rt.Flow(name="Weather Flow", entry_point=WeatherAgent)
result = flow.invoke("What's the weather in Paris?")
# or `await flow.ainvoke("What's the weather in Paris?")` in an async context
print(result.content)  # "Based on the current data, it's sunny in Paris!"

Execution order, branching, and looping are expressed using standard Python control flow.

What is an agent harness?

Everything around the model call. The model brings judgment. The harness brings the loop that keeps calling it, the tools it can reach, what lands in its context, the limits on what it may do, and the record of what it did. Change your model tomorrow and the harness is what you still own.

Five parts. Take the ones your problem needs, wire them together in plain Python, leave the rest out.

Part What it decides Railtracks primitives
Loop When the agent keeps going, and when it's done rt.agent_node runs the tool-calling loop; rt.Flow and rt.call drive multi-step work
Tool surface What the agent can actually do rt.function_node, rt.ToolManifest for agents-as-tools, rt.connect_mcp for MCP servers
Context What the model sees on this turn system_message, rt.context, todo and key-value memory toolsets, retrieval
Controls What it's allowed to do, and how much of it MaxCalls, Timeout, Retry, Lock, human-in-the-loop verifiers, guardrails
Record What happened, and whether you can replay it Session state, railtracks viz, rt.evaluations.evaluate

The shapes this usually takes:

  • Coding harness. Read, edit, and shell tools, a todo list that survives across turns, human approval on anything that touches the working tree. Runnable in examples/harness/coding_harness.py.
  • Research harness. Search and fetch, retrieval over what it has gathered, memory for findings, a structured-output pass to force the report into a schema.
  • Operations harness. A few high-consequence tools, each behind a real approver, with an audit trail you can hand to someone else.

Start with the Agent Harness guide, or run the harness examples as they are: a read-only harness in under 80 lines, and a coding harness whose file writes and shell commands each stop for your approval.

Why Railtracks?

Pure Python

# Write agents like regular functions
@rt.function_node
def my_tool(text: str) -> str:
    return process(text)
  • No YAML, no DSLs, no magic strings
  • Compatible with standard debuggers
  • Full IDE autocomplete and type checking

Tool-First Architecture

# Any function becomes a tool
Assistant = rt.agent_node(
    "Assistant",
    tool_nodes=[my_tool, api_call],
    llm=rt.llm.OpenAILLM("gpt-6-luna"),
)
  • Automatic function-to-tool conversion
  • Seamless API and database integration
  • MCP protocol support

Familiar Interface

# Native Async support
result = await rt.call(Assistant, query)
  • Standardized call interface, consistent with asyncio patterns
  • Built-in validation, error handling, and retries
  • Automatic parallelization management

Built-in Observability

Railtracks includes a visualizer for inspecting agent runs and evaluations in real-time, run completely locally with no signups required.

See the Observability documentation for setup and usage.

Quick Start

Installation
pip install 'railtracks[visual]'
Set your API key

Railtracks loads a local .env file on import, save your provider keys there:

echo "OPENAI_API_KEY=sk-..." >> .env
Building with Claude Code?

Install the Railtracks plugin so Claude Code writes Railtracks code correctly:

claude plugin marketplace add RailtownAI/railtracks
claude plugin install railtracks@railtracks

Using Codex, Copilot, or Cursor? Run railtracks add <assistant>:all (see AI Coding Assistants).

Your First Agent
import railtracks as rt


# 1. Create tools (just functions with decorators!)
@rt.function_node
def count_characters(text: str, character: str) -> int:
    """Count occurrences of a character in text."""
    return text.count(character)


@rt.function_node
def word_count(text: str) -> int:
    """Count words in text."""
    return len(text.split())


# 2. Build an agent with tools
TextAnalyzer = rt.agent_node(
    "Text Analyzer",
    tool_nodes=[count_characters, word_count],
    llm=rt.llm.OpenAILLM("gpt-6-luna"),
    system_message="You analyze text using the available tools.",
)

# 3. Use it to solve the classic "How many r's in strawberry?" problem
text_flow = rt.Flow(name="Text Analysis Flow", entry_point=TextAnalyzer)

result = text_flow.invoke("How many 'r's are in 'strawberry'?")
print(result.content)

LLM Support

Railtracks integrates with major model providers through a unified interface:

# OpenAI
rt.llm.OpenAILLM("gpt-6-luna")

# Anthropic
rt.llm.AnthropicLLM("claude-sonnet-5-5")

# Local models
rt.llm.OllamaLLM("llama3")

Works with OpenAI, Anthropic, Google, Azure, and more. See the full provider list.

Contributing

Railtracks is developed in the open. Contributions, bug reports, and feature requests are welcome via GitHub Issues.

Quick Start Documentation Examples Join Discord


Licensed under MIT · Made by the Railtracks team

Metadata

Release files for railtracks 1.5.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for railtracks 1.5.7
File Size Uploaded
railtracks-1.5.7.tar.gz 401.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for railtracks 1.5.7
File Interpreter ABI Platform
railtracks-1.5.7-py3-none-any.whl Python 3 none any Details

Total release size: 949.6 kB

Release files / railtracks-1.5.7.tar.gz

Download URL railtracks-1.5.7.tar.gz
Size 401.6 kB
Tags Source
SHA-256 checksum
How to use checksums
61763408e1200ae41172f3fdede18deddc8c34bcdc1a4ce1c7a150e4c0ff770e
BLAKE2b-256 checksum
How to use checksums
d1e4e2ed0e14983c9655952842e5118454b776f1b57db5f512ea20170464700a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.34.2

Release files / railtracks-1.5.7-py3-none-any.whl

Download URL railtracks-1.5.7-py3-none-any.whl
Size 548.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d2787f0d1282b0cc23bab6d7b598b1ff06ae37598ff47710d5ffd6295a1e9c1
BLAKE2b-256 checksum
How to use checksums
108f15b4a83e135909c7b21b9ebb44fff5d969cfbdd970481f5a414648c81cc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.34.2

Release history Release notifications | RSS feed

1.115

2 release files

This release

1.5.7 This release

2 release files

1.5.6

2 release files

1.5.5

2 release files

1.5.4

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.7

2 release files

1.4.6

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.10

2 release files

1.3.9

2 release files

1.3.8

2 release files

1.3.7

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.27

2 release files

1.1.26

2 release files

1.1.25

2 release files

1.1.23

2 release files

1.1.22

2 release files

1.1.21

2 release files

1.1.20

2 release files

1.1.19

2 release files

1.1.18

2 release files

1.1.17

2 release files

1.1.14

2 release files

1.1.11

2 release files

1.1.10

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page