nomi

Setup guides · Python

Custom Loop

For an agent that calls a provider's API itself. You wrap each unit of work, each model call and each tool call once, where your loop already makes them.

Versions
Python SDK (nomi-sdk) 1.0.0; any model provider
Route
The Python SDK at the places your loop calls models and tools

Your coding agent can do the attaching. Ask it:

Use the attach-nomi skill and add nomi to this agent.

It finds the places to hook in and asks you the few things only you know. The steps below are what it does.

Start nomi

nomi is one program, nomi. Download it from the releases page, then:

nomi init
nomi configure -mode sdk -source my-agent -receiver-listen 127.0.0.1:4320
nomi start                                   # leave this running
nomi browser -home "$HOME/.nomi"  # opens the run view

Everything it records lives in ~/.nomi; -home on any command chooses another folder. nomi doctor says whether it's healthy.

Install the Python SDK into your agent's environment from the release's wheel (the same file comes with the program; it isn't on the Python package index) and tell it where nomi is:

pip install "nomi-sdk @ https://github.com/joshbodunrin/nomi/releases/download/v1.0.0/nomi_sdk-1.0.0-py3-none-any.whl"
export MYAGENT_NOMI_ENABLED=1
export MYAGENT_NOMI_ENDPOINT=http://127.0.0.1:4320
export MYAGENT_NOMI_TOKEN_FILE="$HOME/.nomi/write-token"

These are the same-machine settings. Your agent can also run in a container or on another machine of yours and send to the same nomi: where nomi runs has what changes, and the attach skill can set it up.

nomi never changes how your agent runs: if it’s off, down or hanging, your agent carries on with the same output.

How it fits

Your loop owns the model calls, the tool dispatch and the retries, and it keeps them. Nothing records automatically here: you mark the places your loop already has, once each, rather than every role or business tool.

Attach

  1. Create one observer where your process starts, and pass it to the code that needs it:

    from nomi import Observer
    
    observer = Observer.from_env("my-agent", project="my-repo", agent="my-agent", prefix="MYAGENT_NOMI")
    

    project names the codebase and agent the agent in it, so one home can hold several agents without mixing their runs. It always returns a usable observer. When it is switched off or set up wrong, every call does nothing and observer.setup says why, so your code needs no checks around it.

  2. Wrap each unit of work a person would debug (a ticket, a pull request, a conversation turn):

    with observer.observe("handle_ticket", workflow="support", group=ticket.id, step="resolve"):
        ...
    

    group joins separate runs of the same item into one work item.

  3. Record each model call with the helper that matches your client:

    reply = observer.anthropic(client.messages.create, request)
    # or observer.responses(...), observer.chat_completions(...)
    

    For anything else (a local model’s own client, streaming, async code), record the call yourself:

    with observer.model_call("llama-3-8b", provider="ollama", input=prompt, max_output_tokens=800) as call:
        text, usage = await stream_and_collect(prompt)
        call.finish(text, usage=usage)
    

    finish takes the reply, the usage (OpenAI, Anthropic or plain counter names, and Ollama’s prompt_eval_count and eval_count; a name it doesn’t read is named on the step, never dropped silently) and, when the model returns it, reasoning= for its thinking text. The local models guide has a full example on Ollama.

  4. Record each tool call. Give a side effect an action_id and an attempt, so a retry reads as a retry of the same action rather than a new one:

    with observer.tool("issue_refund", {"order": order_id}, action_id=f"refund:{order_id}", attempt=str(n)) as call:
        refund = payments.refund(order_id, amount)
        call.result(refund)
        call.effect("committed", f"payments:{refund.id}")
    
  5. Declare what only your code knows (see below).

Recorded

  • Model calls through the helpers: the model, tokens, the output cap your code asked for, and the prompt and reply. With no cap passed, the limit is unknown, not zero.
  • The provider: responses() and chat_completions() say openai only when the client sends to api.openai.com. For any other address the provider is unknown and the step shows where the request went; a provider= you pass to chat_completions() is kept.
  • Reasoning text, kept apart from the reply: what you pass to finish(reasoning=), and a reasoning or reasoning_content field in a Chat Completions reply.
  • The provider client’s own retries: a failed call, or one made with with_raw_response, shows how many attempts the client made. A call that succeeded with a parsed reply says they aren’t reported.
  • Tool calls: arguments, result, duration, errors, and each attempt of one action.
  • Every step’s file, function and line, and the commit that ran, with whether it had uncommitted changes.
  • Events lost while nomi was down, counted and shown on the run once the SDK reaches nomi again in the same process; otherwise only in your agent’s log line.

Declared by your code

  • Decisions: observer.decision("refund_declined", reason) for a result, or kind="issue" for a problem your agent caught itself. Neither marks the run failed.
  • Effects: committed, completed, not_applied or unknown on a tool call.
  • Expected exceptions: from_env(..., expected=(RateLimitWait,)) ends a run as deferred, not failed.
  • Waits: observer.idle("daily_quota", until=resume_at) when your agent waits on purpose, so waiting and hung look different.

What it can’t see

  • Anything your loop doesn’t pass through a helper. Provider responses aren’t understood automatically; the helpers map the fields they support.
  • A stream through chat_completions(..., stream=True): the app reads it after the step ends, so the call has no reply, tokens or end (“reply not observed”). Record a stream with model_call() instead.
  • Hidden reasoning, and content the provider doesn’t return.

In every guide: nothing below a tool’s boundary, such as HTTP retries in your own client, is seen unless your code declares its attempts. Retries inside a provider’s client library show as one longer model call; the step gives the client’s attempts where the route reports them, and otherwise says they aren’t reported. A model nomi has no price for, such as a local one, has its cost shown as unpriced, never as $0. A run that was still open when nomi stopped says its end was not received: its outcome is unknown, not interrupted.

Connect your coding agent

nomi includes a server with read-only tools for your coding agent, and a debug skill that teaches it to keep what was observed, what your code declared and what is unknown apart. Pick yours:

Claude Code

claude mcp add nomi -s user -- nomi mcp
mkdir -p ~/.claude/skills && cp -R skills/debug-agent-with-nomi ~/.claude/skills/

Codex

codex mcp add nomi -- nomi mcp
mkdir -p ~/.codex/skills && cp -R skills/debug-agent-with-nomi ~/.codex/skills/

Cursor, in ~/.cursor/mcp.json (or .cursor/mcp.json for one project)

{"mcpServers": {"nomi": {"type": "stdio", "command": "nomi", "args": ["mcp"]}}}

Cursor's debug skill (the skill needs Cursor 2.4 or later)

mkdir -p ~/.cursor/skills && cp -R skills/debug-agent-with-nomi ~/.cursor/skills/

Cursor also reads skills from ~/.claude/skills/, so if the skills are already installed for Claude Code, nothing needs copying.

Then open a session in your agent's repository and ask, for example:

  • “What went wrong in my agent's last few runs?”
  • “Why did this run fail?”
  • “What changed between these two runs?”