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 commands/codeblockz/langchain-community-plugin/new-agentgit clone --depth 1 https://github.com/Codeblockz/langchain-community-pluginWhat 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.00013 | $0.01237 |
| Opus 5 | $0.00006 | $0.00619 |
| Sonnet 5 | $0.00003 | $0.00247 |
| Haiku 4.5 | $0.00001 | $0.00124 |
Grade A, and why
new-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 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 — 217 lines — stays where its author put it; the contents beside it link to each section on GitHub.
New LangGraph Agent Command
Create a new LangGraph agent file with best practices baked in.
Workflow
-
Ask the user which agent type they want:
create_agent- High-level API, simpler, uses middlewareStateGraph- Low-level API, full control, custom routing
-
Get filename from argument or ask user (default:
agent.py) -
Generate the agent file using the appropriate template below
-
Inform user about next steps (install dependencies, customize tools)
Templates
create_agent Template
"""
LangGraph Agent using create_agent API
Install: pip install langchain langgraph
"""
from langchain.agents import create_agent
from langchain.tools import tool
from langgraph.checkpoint.memory import InMemorySaver
# Define your tools
@tool
def search(query: str) -> str:
"""Search for information.
Args:
query: The search query
"""
# TODO: Implement search logic
return f"Results for: {query}"
@tool
def calculate(expression: str) -> str:
"""Evaluate a mathematical expression.
Args:
expression: Math expression to evaluate
"""
# TODO: Implement safely
return str(eval(expression))
# Create the agent
agent = create_agent(
model="claude-sonnet-4-5-20250929", # or "gpt-4o"
tools=[search, calculate],
system_prompt="You are a helpful assistant.",
checkpointer=InMemorySaver(), # Required for memory/HITL
)
def main():
# Invoke with thread_id for conversation memory
config = {"configurable": {"thread_id": "user-123"}}
result = agent.invoke(
{"messages": [{"role": "user", "content": "Hello!"}]},
config=config
)
for msg in result["messages"]:
print(f"{msg.type}: {msg.content}")
if __name__ == "__main__":
main()
StateGraph Template
"""
LangGraph Agent using StateGraph API
Install: pip install langchain langgraph
"""
from typing import Annotated, Literal
from typing_extensions import TypedDict
from langchain.messages import AnyMessage, HumanMessage, SystemMessage
from langchain.chat_models import init_chat_model
from langchain.tools import tool
from langgraph.graph import StateGraph, START, END
from langgraph.graph.message import add_messages
from langgraph.checkpoint.memory import InMemorySaver
# 1. Define state - MUST be TypedDict
class State(TypedDict):
messages: Annotated[list[AnyMessage], add_messages] # Reducer appends messages
# 2. Define tools
@tool
def search(query: str) -> str:
"""Search for information.
Args:
query: The search query
"""
# TODO: Implement search logic
return f"Results for: {query}"
@tool
def calculate(expression: str) -> str:
"""Evaluate a mathematical expression.
Args:
expression: Math expression to evaluate
"""
# TODO: Implement safely
return str(eval(expression))
# 3. Setup model with tools
tools = [search, calculate]
tools_by_name = {t.name: t for t in tools}
model = init_chat_model("claude-sonnet-4-5-20250929").bind_tools(tools)
# 4. Define nodes
def call_model(state: State) -> dict:
"""Call the model and return response."""
messages = [
SystemMessage(content="You are a helpful assistant."),
*state["messages"]
]
response = model.invoke(messages)
return {"messages": [response]}
def call_tools(state: State) -> dict:
"""Execute tool calls from the last message."""
from langchain.messages import ToolMessage
last_message = state["messages"][-1]
results = []
for tool_call in last_message.tool_calls:
tool_fn = tools_by_name[tool_call["name"]]
result = tool_fn.invoke(tool_call["args"])
results.append(
ToolMessage(content=str(result), tool_call_id=tool_call["id"])
)
return {"messages": results}
# 5. Define routing
def should_continue(state: State) -> Literal["tools", "__end__"]:
"""Route to tools or end based on last message."""
last_message = state["messages"][-1]
if last_message.tool_calls:
return "tools"
return END
# 6. Build and compile graph
builder = StateGraph(State)
builder.add_node("model", call_model)
builder.add_node("tools", call_tools)
builder.add_edge(START, "model")
builder.add_conditional_edges("model", should_continue, ["tools", END])
builder.add_edge("tools", "model")
# Compile with checkpointer for memory/HITL
graph = builder.compile(checkpointer=InMemorySaver())
def main():
# Use thread_id for conversation persistence
config = {"configurable": {"thread_id": "user-123"}}
result = graph.invoke(
{"messages": [HumanMessage(content="Hello!")]},
config=config
)
for msg in result["messages"]:
print(f"{msg.type}: {msg.content}")
if __name__ == "__main__":
main()
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 · 217 lines · 13 tokens per session scan A 09f5598f35bc
new-agent is a command published in the GitHub repository Codeblockz/langchain-community-plugin (3 stars, last pushed 7mo ago), licensed Apache-2.0. It adds 13 tokens to every session and 1,237 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-31.
Other commands, from other repositories
date
询问当天的日期,输出的格式为 yyyy-MM-dd 星期几.
add-eval
Create a new evaluator for assessing agent performance.
add-subgraph
Create a modular subgraph that can be composed into the main workflow.
human-in-the-loop
Add human approval or intervention points to your workflow.
run-evals
Execute the evaluation suite against the LangGraph agent.
add-node
Create a new node in the LangGraph workflow.