A first agent
An agent that reads its task, may run shell commands on this machine, and stops when it answers.
app.tsx is the whole app; affordance.yaml binds it to a model server and a machine.
affordance init writes these same two files into a new directory.
#Run it
Start an OpenAI-compatible model server on port 8080. No key is needed:
shllama-server -m your-model.gguf --port 8080 --jinja # llama.cpp # or: vllm serve <model> --port 8080 # or: ollama serve (then add --set model.url=http://127.0.0.1:11434/v1 --set model.model=<name>)Set
contextinaffordance.yamlto your model's context length (the server's-c).Run the agent from this directory:
shaffordance run
The report prints when the agent stops: "stopped": {"answer": "..."}. Its journal and trace
are in .affordance/first/; affordance run --resume continues the run, --fresh starts over.
For a hosted API, set url, model and context, and key_env: NAME for the environment
variable that holds its key. affordance config shows what a run will use.
tests/first_agent.rs runs this example, as written, against a stand-in server.
Source: examples/first_agent/README.md, about 1 minutes to read.