selectools-agent-core

selectools-agent-core is a cursor rule for Cursor from johnnichev/selectools. It costs 0 tokens per session (456 once invoked), scanned A, original, Apache-2.0.

A set of rules for the main processing loop of an AI coding agent. The loop checks input, memory, cached results, model responses, tool requests, policy, execution results, traces, and usage information.

In plain words
What is it for?
Adding or changing features in the agent’s core loop while keeping results, reasoning, traces, costs, and tool activity recorded consistently.
Why use it?
It provides a defined order for handling requests and tool calls. It also gives new features clear places to connect with configuration, event tracking, and execution records.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Adding or changing features in the agent’s core loop while keeping results, reasoning, traces, costs, and tool activity recorded consistently.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/johnnichev/selectools/selectools-agent-core
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.

Clone the repo
git clone --depth 1 https://github.com/johnnichev/selectools

Made for: Cursor.

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 selectools-agent-core

README.md
[![agentmods](https://agentmods.dev/badge/rules/johnnichev/selectools/selectools-agent-core/github.svg)](https://agentmods.dev/rules/johnnichev/selectools/selectools-agent-core)
Your own site
<a href="https://agentmods.dev/rules/johnnichev/selectools/selectools-agent-core"><img src="https://agentmods.dev/badge/rules/johnnichev/selectools/selectools-agent-core/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for selectools-agent-core

Your own site · 80×15
<a href="https://agentmods.dev/rules/johnnichev/selectools/selectools-agent-core"><img src="https://agentmods.dev/badge/rules/johnnichev/selectools/selectools-agent-core.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 456 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.00456
Opus 5.5 $0.00000 $0.00182
Sonnet 5.5 $0.00000 $0.00091
Haiku 4.5 $0.00000 $0.00046

Measured 1mo ago against content hash 3ec136e3fa8a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

selectools-agent-core 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 1mo 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.

.cursor/rules/selectools-agent-core.mdc · 48 lines

What it actually says

Agent Core Rules

Execution Flow (in order)

  1. Input guardrails validate/redact user message
  2. Memory loads history, provider called (or fallback chain)
  3. Cache checked — hit returns cached response
  4. Provider formats prompt + calls LLM, cache stores result
  5. Output guardrails validate LLM response
  6. Parser extracts TOOL_CALL, reasoning extracted
  7. Policy engine evaluates tool call (allow/review/deny)
  8. Coherence check verifies tool matches user intent
  9. Tool executes (parallel if multiple), output screening applied
  10. Trace records step, audit logger writes, usage tracks costs
  11. Loop continues or returns AgentResult

AgentResult Always Contains

  • .content — final text response
  • .trace — AgentTrace with typed timeline
  • .reasoning — why agent chose tools
  • .usage — aggregated token/cost stats

Integration Points for New Features

When adding a feature that touches the agent loop:

  • Add config fields to agent/config.py
  • Add new StepType to trace.py if recording trace steps
  • Add observer events to observer.py if emitting lifecycle events
  • Guard observer calls with if run_id: for consistency
  • Use _notify_observers() helper, never call observer methods directly
  • Wrap observer calls in try/except to prevent crashing agent

Thread Safety

  • FallbackProvider observer wiring uses threading.Lock + refcount
  • batch() uses ThreadPoolExecutor — each thread gets isolated history
  • abatch() uses asyncio.gather with copied agent instances
  • Direct concurrent arun() on same agent shares _history (known limitation)

Defensive Patterns

  • response_msg.content or "" — providers can return None content
  • elif response_format is None: — prevent parser intercepting structured output
  • _memory_add_many() — ensures on_memory_trim observers fire
  • routing_only path must still fire on_iteration_end
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. 1mo ago First seen · 48 lines · 0 tokens per session scan A 3ec136e3fa8a

Subscribe to this mod's changes

selectools-agent-core is a cursor rule published in the GitHub repository johnnichev/selectools (11 stars, last pushed today), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 456 tokens. 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.