run_agents

A guide to running an AI agent and handling its results. It explains complete responses, streamed responses that arrive in parts, message inputs, and execution limits.

In plain words
What is it for?
Use it to call an agent with one or more messages, read its message-based output, stream results, and limit how long it runs.
Why use it?
It removes uncertainty about the format an agent expects and the shape of the data it returns. It also helps you choose between waiting for a full answer and showing output as it arrives.

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/langchain-ai/langgraphjs/run_agents
Clone the repo
git clone --depth 1 https://github.com/langchain-ai/langgraphjs
Per session 0 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,312 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.00000 $0.01312
Opus 5 $0.00000 $0.00656
Sonnet 5 $0.00000 $0.00262
Haiku 4.5 $0.00000 $0.00131

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

Security

Grade A, and why

run_agents 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 3d 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.

docs/docs/agents/run_agents.md · 150 lines

How it starts

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

Running agents

Agents support execution using either .invoke() for full responses, or .stream() for incremental streaming of the output. This section explains how to provide input, interpret output, enable streaming, and control execution limits.

Basic usage

Agents can be executed using .invoke():

import { createReactAgent } from "@langchain/langgraph/prebuilt";

const agent = createReactAgent(...);

// highlight-next-line
const response = await agent.invoke(
  { messages: [ { role: "user", content: "what is the weather in sf" } ] }
);

Inputs and outputs

Agents use a language model that expects a list of messages as an input. Therefore, agent inputs and outputs are stored as a list of messages under the messages key in the agent state.

Input format

Agent input must be an object with a messages key. Supported formats are:

Format Example
String { messages: "Hello" } — Interpreted as a HumanMessage
Message object { messages: { "role": "user", "content": "Hello" } }
List of messages { messages: [ {"role": "user", "content": "Hello" } ] }
With custom state { messages: [ {"role": "user", "content": "Hello"} ], "user_name": "Alice" } — If using a custom stateSchema

Messages are automatically converted into LangChain's internal message format. You can read more about LangChain messages in the LangChain documentation.

Read the full file on GitHub · 150 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. 3d ago First seen · 150 lines · 0 tokens per session scan A 60d60c4be6cc

Subscribe to this mod's changes

run_agents is an agent published in the GitHub repository langchain-ai/langgraphjs (3,242 stars, last pushed 7d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,312 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.

Related

Other agents, from other repositories

experiment

The experiment agent of /auto. Wraps the /auto-experiment skill, which folds mechanism-family routing inline before implementing, code-reviewing, and deploying the experiment suite. Supports two-step invocation — first call returns candidate families for the orchestrator's mini-prompt, second call (with chosenfamily)…

zjunlp/Mechanist · 72 tokens

iteration

The iteration agent of /auto. Runs the /auto-iteration-loop skill — an autonomous review loop that consumes /auto-verify's four-state output (PASS / FAIL / INCONCLUSIVE / ZEROELIGIBLEVARIANTS) plus the orthogonal deferred bucket and routes each claim to the right back-edge (① variant-only fix / ② baseline-script fix /…

zjunlp/Mechanist · 143 tokens

huyen-agents

Updated 2025: This is a summary of Chip Huyen's blog and book chapter on agents, with some added context to provide a comprehensive overview of their design, capabilities, and practical applications.

alirezadir/Agentic-AI-Systems · 0 tokens

designer

Ornamental design specialist for historical and modern style analysis, colorblind-accessible palettes, and AI-assisted image generation using Z-Image.

pjt222/agent-almanac · 29 tokens

diffusion-specialist

Diffusion process specialist bridging cognitive drift-diffusion models and generative AI diffusion models for parameter estimation and implementation.

pjt222/agent-almanac · 27 tokens

api-reviewer

Review Hono API routes for consistency, security, and best practices.

dafthunk-com/dafthunk · 17 tokens