schema

A documented schema module for turning an AI agent’s earlier actions and observations into a prompt scratchpad. A scratchpad is the working history an agent passes back to the language model.

In plain words
What is it for?
Use it with classic ReAct agents and chat prompt templates that need an agent-scratchpad variable.
Why use it?
It helps the model receive prior reasoning and tool results in the prompt so it can continue the agent loop.

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/xt765/langchain-chinese-comment/schema
Clone the repo
git clone --depth 1 https://github.com/xt765/LangChain-Chinese-Comment
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 569 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.00569
Opus 5 $0.00000 $0.00284
Sonnet 5 $0.00000 $0.00114
Haiku 4.5 $0.00000 $0.00057

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

Security

Grade A, and why

schema 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.

code_comment/libs/langchain/langchain_classic/agents/schema.md · 36 lines

What it actually says

libs\langchain\langchain_classic\agents\schema.py

此文档提供了 libs\langchain\langchain_classic\agents\schema.py 文件的详细中文注释。该模块定义了用于处理代理“草稿本”(Scratchpad)的特定提示词模板类。

功能描述

在代理的推理循环中,模型需要看到自己之前的思考过程和工具执行结果。schema.py 提供了一个专门的 ChatPromptTemplate 子类,用于将这些中间步骤格式化并注入到提示词中。

核心类:AgentScratchPadChatPromptTemplate

该类继承自 ChatPromptTemplate,专门用于管理聊天代理的推理轨迹。

1. 核心方法

_construct_agent_scratchpad(intermediate_steps)
  • 作用: 将历史步骤列表转换为文本。
  • 输入: list[tuple[AgentAction, str]](动作与观察结果的对)。
  • 逻辑: 遍历历史,将 action.log(包含思考和动作指令)与 observation 拼接。
  • ReAct 风格: 它会在结尾添加 "Thought: ",引导 LLM 进行下一步思考。
_merge_partial_and_user_variables(**kwargs)
  • 作用: 变量预处理。
  • 逻辑: 从输入变量中提取 intermediate_steps,将其转换为 agent_scratchpad 字符串,从而使 Prompt 模板中的 {agent_scratchpad} 占位符能够被正确填充。

2. 序列化说明

  • is_lc_serializable: 返回 False。这意味着该特定的模板类不支持标准的 LangChain 序列化流程。

设计模式与现状

  • 草稿本模式: 这是经典 ReAct 代理的核心设计。它通过在 Prompt 中不断追加“思考-行动-观察”的历史,来维持模型的上下文意识。
  • 局限性: 将所有历史转换为单一字符串在处理长对话或复杂工具输出时效率较低,且容易超出上下文窗口。
  • 现代替代方案:
    • 现代 LangChain 代理(如 OpenAIToolsAgent)通常使用消息序列(AIMessage + ToolMessage)来替代这种文本拼接方式。
    • 格式化逻辑已解耦到独立函数中(如 format_to_openai_tools)。
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 · 36 lines · 0 tokens per session scan A d7aa994ef0a9

Subscribe to this mod's changes

schema is an agent published in the GitHub repository xt765/LangChain-Chinese-Comment (20 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 569 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

build-error-resolver

빌드 실패·타입 에러·컴파일 오류·import 에러·의존성 이슈를 최소 변경으로 그린 복구. 리팩토링·아키텍처 변경 절대 금지. Use proactively when CI/빌드가 빨간불이거나, 터미널에 타입 에러·컴파일 에러가 표시될 때 즉시. 런타임 로직 버그는 systematic-debugger, 아키텍처 변경은 architect 사용.

sangrokjung/claude-forge · 106 tokens

strategic-advisor

Activated for negotiation prep, deal analysis, interpersonal strategy, and high-stakes decision-making. Combines game theory with psychological awareness.

winstonkoh87/Athena-Public · 31 tokens

integration-reviewer

Runtime integration validator — read-only. Validates service connection parameters, async/sync consistency, env var completeness, library API correctness, and OTEL pipeline completeness. Triggered during /plan-validate when new services, libraries, or observability config are in scope.

FlorianBruniaux/claude-code-ultimate-guide · 57 tokens

planner

Strategic planning agent — read-only exploration before implementation. Use to decompose tasks, analyze codebases, and produce a detailed plan. Never modifies files.

FlorianBruniaux/claude-code-ultimate-guide · 33 tokens

devops

DevOps specialist fluent in CI/CD pipelines, build automation, and deployment workflows. Thinks in reliability, security, and developer experience. Designs GitHub Actions, configures build systems, manages secrets. Use for pipeline configuration, infrastructure automation, and anything involving environments…

rjmurillo/ai-agents · 63 tokens

ticket-gate

Ticket readiness gate for actual-mcp-server (forge-kit ticket-gate v6). Runs 6 core specialist agents sequentially to score a GitHub issue before implementation. Each agent scores 1-10; ALL must score 10 to pass. An agent whose domain the ticket does not touch auto-scores 10 (N/A). Extra specialists are added by…

agigante80/actual-mcp-server · 228 tokens