Skip to main content

nuagent

An AI agent that speaks Nu

Powered by Nu PyPI - Python Version PyPI Package


A tool-calling agent picks one registered function per turn and answers with JSON. Six steps, six round trips, every branch routed back through the model.

Here the action is a program. The model writes one Nu term, an immutable expression tree, that reads, branches and writes against the Refs you bound. nuagent runs it and feeds back what it yielded plus the state it left behind.

def out():
    return nu.ForEachDo(
        nu.Iter(nu.Literal(["mon", "tue", "wed"])),
        Notes.items.append(nu.AttrRef("item")),
    ) >> Notes.count.set(nu.Len(Notes.items)) >> Run.done.set(True)

A loop, three writes, a derived count and the run ending itself. One reply.

  • Nothing to register, no schema to keep in sync. Capability is the set of Refs bound around the loop, so bind a different set and it is a different agent with the same code.
  • Reach is whatever Nu reaches: a dict, a nu.kv store on disk, an http service, anything a fabric backs. The shipped catalogue is nucore only, so finding a fabric's verbs costs the model a turn.
  • The loop is a term as well: a WhileDo over the turn, no python driver. Swap MemSession for KVSession and the same run is durable.

Installation

Requires Python 3.10+.

pip install nuagent

Usage

An agent over a notes list. The app's Shape goes into the prompt, so the model opens the run already knowing the slot names and their types.

import nu, nuagent


class Notes(nu.Shape):
    items = nu.mem.ListRef.slot(str)
    count = nu.mem.IntRef.slot()


class Bot(nu.Service):
    chat = nu.llm.ChatRef.method(temperature=0)


TASK = """\
Append one note per weekday to `items`, then set `count` to how many notes are
in the list. Do it as one program, and derive the count."""

system = nuagent.system_prompt(
    TASK,
    sections=nuagent.inserted(nuagent.DEFAULT_SECTIONS, nuagent.surface_section((Notes,))),
)

loop = nuagent.agent(
    session=nuagent.MemSession,
    chat=Bot.chat,
    state=nu.Dict.of(items=Notes.items, count=Notes.count),
    start=nuagent.MemSession.messages.set(
        nu.List.of(nu.Dict.of(role="system", content=nu.Str(system))),
    )
    >> Notes.items.set([])
    >> Notes.count.set(0),
    report=nu.print(nu.Str("\nnotes: ") + nu.ToStr(nu.Repr(Notes.items))),
)

nu.run(
    nu.With(
        nu.Provide(dict, {}),
        nu.llm.ollama(Bot, host="localhost", model="qwen2.5:7b-instruct"),
        body=loop,
    )
)

Status

Early. The API is not settled yet.

Metadata

Release files for nuagent 0.1.2

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

Source distribution (sdist)

Source distribution for nuagent 0.1.2
File Size Uploaded
nuagent-0.1.2.tar.gz 41.6 kB Details

Built distribution (wheel)

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

Total release size: 78.3 kB

Release files / nuagent-0.1.2.tar.gz

Download URL nuagent-0.1.2.tar.gz
Size 41.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b5408a2160a61ab2935ff14339335c2db3476fb35b10a62e039ebe6edcca5bff
BLAKE2b-256 checksum
How to use checksums
98fea3c2db72b06e6fbbbef39c9577c2e888cf4cf8265b41fd2c79fc2eb7945f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release files / nuagent-0.1.2-py3-none-any.whl

Download URL nuagent-0.1.2-py3-none-any.whl
Size 36.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc35c2661580de956c5534458f69b2c7b924c6559d8fec57dfbf5402e4b82973
BLAKE2b-256 checksum
How to use checksums
8a6c07cb65b39f99d61ea999164bec07190cc24a295266ec8be9fbd17e2b221a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

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