Neurosurfer helps you build intelligent apps that blend LLM reasoning, tools, and retrieval, with a ready-to-run OpenAI-compatible FastAPI gateway. Start lean, add power as you go.
📰 What's new
- Observability: pluggable trace exporters (latest): ship every agent run to a real monitoring backend with no code changes. Ships with Langfuse (traces, token cost, sessions) and OpenTelemetry (GenAI-semconv spans over OTLP → Phoenix / Grafana / Datadog). Auto-on from the environment; runs → traces, LLM turns → generations, tool calls → spans, sub-agents & workflow nodes nest automatically.
pip install "neurosurfer[observability]"; see Observability. - Trace nesting & sessions: a run spawned inside another run nests under it in the same trace (propagated across
awaitandasyncio.gather); agents accept asession_idso a whole conversation groups into one session. - v1.0.0: first stable release (2026-07-01): the public API (
neurosurfer.agents,.llm,.tools,.rag,.graph,.architect,.mcp,.app.server) is now stable under semantic versioning.
Full history in the Changelog.
📦 What's in the box
- 🤖 Agent family:
AgenticLoop(native multi-step tool-use),ReactAgent(text-parsing ReAct for models without a native tool API), andAgent(one-shot, optionally with structured output). - 🧠 LLM providers: Anthropic Claude, OpenAI, and any OpenAI-compatible server (Ollama, LM Studio, vLLM, llama.cpp) behind one
Providerprotocol. - 🔧 Rich tool ecosystem: 15+ built-in tools: web search (DuckDuckGo/SerpAPI), sandboxed Python execution, file ops, HTTP, headless browser, and memory, plus a simple framework for your own.
- 📚 RAG pipeline: ingest → chunk → embed → retrieve → token-aware context injection.
- 🕸️ Graph & Workflows: a standalone DAG engine and persisted, runnable Workflow packages.
- 🏗️ Architect: describe a workflow in plain English; it designs and builds the graph for you.
- 🔌 MCP client: connect external Model Context Protocol servers and expose their tools to agents.
- ⚙️ OpenAI-compatible gateway:
/v1/models+/v1/chat/completionswith SSE streaming; proxy upstream backends or route to your own agents; request/response hooks. - 🔭 Observability: pluggable trace exporters (Langfuse, OpenTelemetry) with zero-overhead-when-off tracing.
- 🧪 Interactive CLI: a
neurosurferREPL for chat andneurosurfer servefor the gateway.
🎓 Tutorials
Hands-on notebooks: open any of them directly in Google Colab.
| # | Tutorial | What you'll build |
|---|---|---|
| 0 | Installation | Install Neurosurfer and its optional extras; verify your setup. |
| 1 | Providers & Agents | Connect cloud and local providers, then run AgenticLoop, ReactAgent, and one-shot Agent. |
| 2 | Custom Tools | Write your own tools and give agents new capabilities. |
| 3 | Graph Agents | Compose multi-step workflows with the graph engine and Workflow packages. |
| 4 | MCP Servers | Connect external Model Context Protocol servers and expose their tools to agents. |
| 5 | Capstone: Insight Engine | Put it all together: a database-backed insight engine over MCP. |
⚡ Quick start
Install:
pip install -U neurosurfer
# with web search + gateway:
pip install -U "neurosurfer[search,serve]"
Run the interactive CLI:
neurosurfer
Run the OpenAI-compatible gateway:
neurosurfer serve --host 0.0.0.0 --port 8000
# proxy an upstream backend:
neurosurfer serve --upstream-url http://localhost:1234
Multi-step agent (Anthropic):
import asyncio, os
from pathlib import Path
from neurosurfer.llm.providers.anthropic import AnthropicProvider
from neurosurfer.agents import AgenticLoop, Guardrails
from neurosurfer.tools import default_pool
provider = AnthropicProvider(api_key=os.environ["ANTHROPIC_API_KEY"], model="claude-opus-4-8")
class AutoIO: # auto-approving IOHandler for scripts (see the Agents guide)
async def ask(self, question, options=None): return (options or ["yes"])[0]
async def request_plan_approval(self, plan): return True, ""
async def request_shell_approval(self, command, reason): return True
async def request_write_approval(self, path, summary): return "once"
def notify(self, message): pass
async def main():
agent = AgenticLoop(
provider=provider, tools=default_pool(),
system_prompt="Use tools to answer, then finish.",
guardrails=Guardrails(), io=AutoIO(), cwd=Path.cwd(),
)
async for event in agent.run("Search the web for the latest news on AI agents."):
if hasattr(event, "text"):
print(event.text, end="", flush=True)
asyncio.run(main())
One-shot with structured output:
import asyncio
from pathlib import Path
from pydantic import BaseModel
from neurosurfer.agents import Agent, Guardrails
from neurosurfer.tools import default_pool
class Summary(BaseModel):
title: str
points: list[str]
agent = Agent(
provider=provider, tools=default_pool(),
system_prompt="Answer concisely.",
guardrails=Guardrails(), io=AutoIO(), cwd=Path.cwd(),
output_schema=Summary,
)
result = asyncio.run(agent.complete("Summarise the Neurosurfer framework in 3 bullet points."))
print(result.title, result.points) # `result` is a validated Summary instance
Register an agent as an OpenAI-compatible model:
from neurosurfer.app.server import NeurosurferServer
from neurosurfer.agents import AgenticLoop
server = NeurosurferServer()
server.register_agent(AgenticLoop(provider=provider), model_id="my-agent")
server.run() # → http://localhost:8000/v1/chat/completions
🔭 Observability
See and debug what your agents actually do in a real dashboard: the LLM turns, tool calls, token usage, and cost. Tracing is a cross-cutting, side-channel layer: it observes the event stream every agent already emits, never consumes it, so nothing about how you call agent.run(...) changes.
- Zero code changes: auto-on from the environment. Set a backend's connection vars and it activates on the next run.
- Two backends in the box: Langfuse (batteries-included LLM observability) and OpenTelemetry (vendor-neutral GenAI-semconv spans over OTLP → Honeycomb, Phoenix, Grafana Tempo, Datadog…). Or write your own
TraceExporter. - Automatic nesting: a run is a trace; each LLM turn a generation (with token cost); each tool call a span; spawned sub-agents and workflow nodes nest under the parent (
workflow → node → agent → tool). - Safe by design: zero overhead when off, and a misbehaving or unreachable exporter never breaks a run.
pip install "neurosurfer[observability]"
# Langfuse: auto-detected from the environment
export LANGFUSE_PUBLIC_KEY=pk-... LANGFUSE_SECRET_KEY=sk-...
# …or any OTel backend:
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
That's it. Run any agent and the traces show up. Full guide: Observability docs.
🧩 Install options
| Extra | What you get |
|---|---|
| (base) | Agents, LLM providers, tools, RAG, server, CLI |
search |
Web search tool (DuckDuckGo, BM25 ranking, HTML extraction) |
browser |
Headless browser tool via Playwright |
local |
tiktoken for accurate token counting with local models |
rag |
ChromaDB, sentence-transformers, PDF/DOCX/PPTX readers |
serve |
FastAPI + uvicorn for the OpenAI-compatible gateway |
mcp |
Model Context Protocol client SDK |
observability |
Langfuse + OpenTelemetry trace exporters |
dev |
pytest, ruff, mypy, build tools |
pip install "neurosurfer[search,serve,rag,observability]"
📄 License
Licensed under the Apache-2.0 License. See LICENSE.
💬 Support
- Star the project on GitHub
- Ask & share in Discussions
- File Issues
- Security: report privately to naumanhsa965@gmail.com
📚 Citation
@software{neurosurfer,
author = {Neurosurfer Team},
title = {Neurosurfer: A Production-Ready AI Agent Framework},
year = {2026},
url = {https://github.com/NaumanHSA/neurosurfer},
license = {Apache-2.0}
}
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neurosurfer-1.0.0.tar.gz.
File metadata
- Download URL: neurosurfer-1.0.0.tar.gz
- Upload date:
- Size: 2.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
649cd684ea40988923996c1122f45eec817e2394c1129d6852a9be7ffad29058
|
|
| MD5 |
d1bea21429752a7d1a9391380e172c33
|
|
| BLAKE2b-256 |
7e92153c46d5b68cf70211d32378c91f5f0cc8ffd72ee6c94aa32e189935899a
|
File details
Details for the file neurosurfer-1.0.0-py3-none-any.whl.
File metadata
- Download URL: neurosurfer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 404.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8817778eebf61a42d82acc021afdf7c0badc83d0fdc2cb3270441f55f9f84bfa
|
|
| MD5 |
4f029c668b731b4f874894cd552143df
|
|
| BLAKE2b-256 |
c40bf201f39c7edec69fb3788c7e3e543d37f23d9c6b0f45d7f6cc0808108bc8
|