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.
npx agentmods add rules/altaidevorg/rules-for-ai/runnergit clone --depth 1 https://github.com/altaidevorg/rules-for-aiWhat 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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.03155 | $0.03155 |
| Opus 5 | $0.01577 | $0.01577 |
| Sonnet 5 | $0.00631 | $0.00631 |
| Haiku 4.5 | $0.00315 | $0.00315 |
Grade A, and why
runner 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 yesterday.
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.
How it starts
The opening of the file, as written. The whole thing — 235 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Chapter 1: Runner
Welcome to the google-adk tutorial! This first chapter introduces the Runner, a fundamental component responsible for managing the entire lifecycle of an agent interaction within the framework.
Motivation and Use Case
Imagine you have built an agent, perhaps using an LLM, that can interact with users. How do you actually run this agent? You need a system that can:
- Receive user input.
- Maintain the conversation history (Session).
- Manage persistent state (State).
- Handle file uploads/downloads (Artifacts).
- Potentially retrieve relevant long-term memories.
- Invoke the correct agent logic.
- Stream back the agent's response (Events).
- In complex systems with multiple agents, decide which agent should handle the current turn.
The Runner is the orchestrator that handles all these tasks. It acts as the main entry point for interacting with any agent built using google-adk.
Central Use Case: A user sends a message ("What's the weather in London?") to your weather agent via an application. The application uses a Runner instance. The Runner retrieves the ongoing conversation session, appends the new user message, determines the weather agent should handle it, calls the agent's execution logic, and streams the resulting events (like the agent thinking, calling a weather tool, and finally responding) back to the application.
Key Concepts
- Orchestration: The
Runnercoordinates the flow of information and control between the user, the agent(s), and various backing services. - Agent Execution: It provides methods like
run_async(asynchronous, recommended for production) andrun(synchronous wrapper for testing) to execute an agent turn. It also supports an experimentalrun_livefor real-time streaming interactions (e.g., voice). - Service Integration: It requires and utilizes services for managing different aspects of the interaction:
BaseSessionService: Manages conversational Sessions, including history (Events) and State.BaseArtifactService: Handles storage and retrieval of binary data (e.g., files uploaded by the user or generated by the agent). (Optional)BaseMemoryService: Provides access to long-term memory for the agent. (Optional)
- Agent Selection: In systems with a hierarchy of agents (an agent containing sub-agents), the
Runnerdetermines which agent is best suited to handle the current turn based on the session history and agent capabilities (using_find_agent_to_run). It checks if the last responding agent can "transfer" control back up the hierarchy if needed. - Input Processing: Before invoking the agent, the
Runnerprocesses the incoming user message (new_message). This includes potentially saving any attached binary data as artifacts (ifsave_input_blobs_as_artifactsis true in theRunConfig) and appending the user message as an Event to the Session. - Event Streaming: The
run_asyncandrun_livemethods are asynchronous generators thatyieldEvents as they occur during the agent's execution (e.g., intermediate thoughts, tool calls, final response parts).
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.
- yesterday First seen · 235 lines · 3,155 tokens per session scan A 0cbfbc2f89b9
runner is a cursor rule published in the GitHub repository altaidevorg/rules-for-ai (2 stars, last pushed 1y ago), licensed MIT. It adds 3,155 tokens to every session, about $0.0158 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-31.
Other cursor rules, from other repositories
050-plan
When the user types /plan or asks to create a project plan, feature PRD, or retrospective.
dreamd-recall
Recall lessons, decisions, and prior context from the .agent/ memory daemon. Use when starting work in a project that has a .agent/ folder, when the user references a past decision, or when you are about to make a choice that has a documented prior.
session-memory
Use at conversation wrap-up or when the user explicitly indicates end-of-session — capture residual lessons not captured in-flight.
context-recorder-system
Context Recorder System (记录员系统) - 模块化索引文件.
rules
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
misc-documenting-learnings-and-clarifying-assumptions
Documenting Learnings and Clarifying Assumptions for Efficient Task Execution.