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
nustd.kvstore 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
WhileDoover the turn, no python driver. SwapMemSessionforKVSessionand 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
import nustd
import nuagent
class Notes(nu.Shape):
items = nustd.mem.ListRef.slot(str)
count = nustd.mem.IntRef.slot()
class Bot(nu.Service):
chat = nustd.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, {}),
nustd.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.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nuagent-0.1.3.tar.gz | 41.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nuagent-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 79.0 kB
Release files / nuagent-0.1.3.tar.gz
| Download URL | nuagent-0.1.3.tar.gz |
|---|---|
| Size | 41.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
02ed30f0b1c7064503114da7de4a91bc5fe93c23996d3c2bbe2fbb666610d23d
|
|
BLAKE2b-256 checksum How to use checksums |
467a21bbfad202a3d918348d26a096515555d329f9943aa718cae88acf52853d
|
| 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 15, 2026.
Transparency logRelease files / nuagent-0.1.3-py3-none-any.whl
| Download URL | nuagent-0.1.3-py3-none-any.whl |
|---|---|
| Size | 37.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
698bf412763ae459f50b95428b57a767efe1c95b1702f826cbfc0c0206c8185c
|
|
BLAKE2b-256 checksum How to use checksums |
8b17f5fd47ec5c2db777ac4e7e29873d660f0ff7dbf801a8f30a941684198385
|
| 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 15, 2026.
Transparency log