first-agent

first-agent is an agent for coding agents from cubeplexai/cubepi. It costs 23 tokens per session (1,449 once invoked), scanned A, original, MIT.

A step-by-step guide for creating and running a first CubePi AI agent. It explains how to connect a language model, define a tool, and add features such as streaming, error handling, and cancellation.

In plain words
What is it for?
Building a first CubePi agent, choosing an AI provider and model, adding asynchronous tools, and extending the agent with a user interface and runtime controls.
Why use it?
It gives newcomers a complete starting path instead of requiring them to assemble provider, model, agent, and tool setup from separate references.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/cubeplexai/cubepi/first-agent
Clone the repo
git clone --depth 1 https://github.com/cubeplexai/cubepi

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for first-agent

README.md
[![agentmods](https://agentmods.dev/badge/agents/cubeplexai/cubepi/first-agent.svg)](https://agentmods.dev/agents/cubeplexai/cubepi/first-agent)
Your own site
<a href="https://agentmods.dev/agents/cubeplexai/cubepi/first-agent"><img src="https://agentmods.dev/badge/agents/cubeplexai/cubepi/first-agent.svg" alt="Measured on agentmods" height="20"></a>
Per session 23 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,449 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00023 $0.01449
Opus 5 $0.00012 $0.00724
Sonnet 5 $0.00005 $0.00290
Haiku 4.5 $0.00002 $0.00145

Measured 5d ago against content hash 40f6177e655b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

first-agent scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

website/docs/guides/agents/first-agent.md · 178 lines

How it starts

The opening of the file, as written. The whole thing — 178 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Building Your First Agent

This guide is the longer cousin of the Quick Start. We'll build a single-tool agent end-to-end, then layer on the things you'll want next: streaming UI, error handling, and a cancel button.

Step 1 — set up the provider and model

The provider is the connection to the LLM API; provider.model("id", ...) binds a model id to that provider and produces the value Agent(model=...) expects.

import os
from cubepi.providers.anthropic import AnthropicProvider

provider = AnthropicProvider(provider_id="anthropic", api_key=os.environ["ANTHROPIC_API_KEY"])
model = provider.model(
    "claude-sonnet-4-6",
    max_tokens=4096,         # response cap
    context_window=200_000,  # hard model limit; defaults are usually fine
    temperature=0.7,
)

provider_id lives on the provider constructor and is propagated into the bound model automatically — used by the framework to gate reasoning fields and tag responses. Building a Model by hand and passing both provider= and model= to Agent is the 0.6 idiom and no longer works in 0.7.

Step 2 — declare a tool

A tool is an async function decorated with @tool:

from cubepi import tool


@tool
async def get_weather(city: str) -> str:
    "Get current weather for a city. Returns a short text summary."
    # do real work here — call an HTTP API, query a DB, etc.
    return f"72°F and sunny in {city}"

A few details:

  • The input schema is generated from the typed parameters and sent to the model; the docstring becomes the tool description. Pydantic Field(...) defaults and metadata are honoured.
  • Return a str (wrapped as text), a Content, a list of content, or a full AgentToolResult when you need details/is_error.
  • Need cancellation or progress streaming? Declare signal (an asyncio.Event set when the user cancels) and/or on_update(partial) in the signature and CubePi injects them — see Tool Use.
  • For a shared params model or dynamic construction, the longhand AgentTool(...) is equivalent — see Tool Use.

Read the full file on GitHub · 178 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 178 lines · 23 tokens per session scan A 40f6177e655b

Subscribe to this mod's changes

first-agent is an agent published in the GitHub repository cubeplexai/cubepi (43 stars, last pushed 2d ago), licensed MIT. It adds 23 tokens to every session and 1,449 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.