create-atomic-context-provider
できること
このガイドは、実行のたびにエージェントのシステムプロンプトに見出し付きのブロックを追加する、コンテキストのプロバイダーを書く方法を説明します。エージェントに、現在の情報や取得した情報を知らせたい開発者向けです。
使う場面
- ✓開発者が、呼び出しのたびに、エージェントに現在の時刻やユーザーの身元を知らせたいとき。
- ✓開発者が、取得した文書をエージェントのプロンプトに挿入したいとき。
- ✓2つのエージェントが同じセッション情報を共有する必要があるとき。
スキルのリンク
https://github.com/Eigenwise/atomic-agents/blob/main/claude-plugin/atomic-agents/skills/create-atomic-context-provider/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“現在のユーザーの名前と保存された設定を、私のエージェントに渡すコンテキストのプロバイダーを追加してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このスキルは、データがどこから来るか、どれくらい新しい必要があるかを尋ねてから、見出し付きのブロックを返すプロバイダーのクラスを書き、それをエージェントに登録します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Create an Atomic Agents Context Provider
A context provider injects a named, titled block into the agent's system prompt at every run(). The base prompt stays static; the context is what changes between calls.
For deep material (caching strategies, async data sources, multi-agent sharing patterns), the authority is ../framework/references/context-providers.md. This skill is the action-oriented path: clarify → write → register.
When this fires vs the umbrella framework skill
- This skill: the user wants to add a provider — "inject the user's name", "make the agent see the current time", "feed retrieved docs into the prompt", "share session state across two agents".
frameworkskill: questions about Atomic Agents in general, or about something other than authoring a provider.
Phase 1 — Clarify
Bundle into one message:
- What goes into the prompt? One sentence. Defines the provider's job.
- Where does the data come from? In-memory state mutated by your code? A vector DB lookup? A REST call? A clock?
- How fresh must it be? Per-
run()(default), every N seconds (cache), or refreshed externally before each call (async data). - Which agent(s)? One agent, or shared across multiple agents?
Skip what's already obvious from context.
Phase 2 — Plan
Confirm in one short block:
- File:
<project>/context_providers.py(or alongside the agent that owns it). - Class:
<Topic>Ctx(BaseDynamicContextProvider). - Title (rendered as the section header in the prompt) — must be unique across providers on the same agent.
- Update mechanism: mutate fields between
run()calls (most common), set via a method, orawait refresh()for async sources.
Phase 3 — Implement
Skeleton
from atomic_agents.context import BaseDynamicContextProvider
class UserCtx(BaseDynamicContextProvider):
def __init__(self):
super().__init__(title="User Context")
self.name: str = ""
self.role: str = ""
def get_info(self) -> str:
if not self.name:
return "No user is logged in."
return f"User: {self.name} (role: {self.role})"
get_info() is synchronous and runs on every agent.run() — keep it cheap. No HTTP, no DB queries, no file I/O. Cache slow sources (see "Cached" pattern below). For async data sources, await provider.refresh() from your loop before calling the agent.
Common patterns
Time — read-only, no state mutation needed:
from datetime import datetime, timezone
class TimeCtx(BaseDynamicContextProvider):
def __init__(self):
super().__init__(title="Current Time")
def get_info(self) -> str:
return datetime.now(timezone.utc).isoformat()
RAG / retrieved docs — set externally, read inside get_info():
class RAGCtx(BaseDynamicContextProvider):
def __init__(self):
super().__init__(title="Retrieved Documents")
self.docs: list[dict] = []
def set(self, docs: list[dict]) -> None:
self.docs = docs
def get_info(self) -> str:
if not self.docs:
return "No relevant documents retrieved."
return "\n\n".join(f"[{d['source']}] {d['content']}" for d in self.docs)
# In the calling code, just before agent.run():
rag.set(vector_db.search(query, k=4))
agent.run(query_input)
Session — mutable key/value state shared across agents:
class SessionCtx(BaseDynamicContextProvider):
def __init__(self):
super().__init__(title="Session")
self._data: dict[str, str] = {}
def set(self, key: str, value: str) -> None:
self._data[key] = value
def get_info(self) -> str:
if not self._data:
return "No session state."
return "\n".join(f"- {k}: {v}" for k, v in self._data.items())
Cached — for slow sources (DB schema, expensive computation):
import time
class DBSchemaCtx(BaseDynamicContextProvider):
def __init__(self, conn, ttl_seconds: int = 300):
super().__init__(title="Database Schema")
self._conn = conn
self._ttl = ttl_seconds
self._cached: str = ""
self._at: float = 0.0
def get_info(self) -> str:
now = time.time()
if not self._cached or now - self._at > self._ttl:
self._cached = render_schema(self._conn)
self._at = now
return self._cached
Async source — refresh outside, read sync inside:
clas
よくある質問
コンテキストのプロバイダーとは何ですか?
エージェントの実行時に、システムプロンプトに名前付きのセクションを追加するコードの部品です。
ベースのプロンプトは変わりますか?
いいえ。ベースのプロンプトは同じままで、呼び出しごとに挿入されるコンテキストだけが変わります。
1つのプロバイダーを複数のエージェントで使えますか?
はい。エージェントの間でプロバイダーを共有する方法を扱っています。
詳細
作者による元の説明
Build a `BaseDynamicContextProvider` that injects a named, titled block into an agent's system prompt at every `run()` — current time, user identity, retrieved RAG docs, session state, cached DB schema. Use when the user asks to "add a context provider", "inject X into the prompt", "give the agent dynamic context", "wire up RAG", "make a `BaseDynamicContextProvider`", or runs `/atomic-agents:create-atomic-context-provider`.
repo: Eigenwise/atomic-agents
人気
- GitHubのスター
- 6.3k
- ランキング
- #14238
- ライセンス
- MIT
- 更新日
- 2026/10/29
コメント
- …
このリポジトリの他のスキル
create-atomic-agent
6.3kエージェントが、型付きの入力と出力、システムプロンプト、選んだAIプロバイダーを持つ新しいAtomic Agentsのエージェントを作れるよう支援します。
create-atomic-schema
6.3kエージェントが、明確なフィールドの説明とともに、Atomic Agentsのエージェントとツールのための型付きの入力と出力のスキーマを設計できるよう支援します。
create-atomic-tool
6.3kAtomicAgentsアプリ向けに、エージェントが呼び出せる型付きツールを作成するのを支援します。
framework
6.3kAtomic AgentsのPythonフレームワークを正しく使えるよう、エージェントを支援します。スキーマ、エージェント、ツール、プロバイダー設定が対象です。
似ているスキル
add-model-provider
394k安全なセットアップコマンドで新しいAIモデルプロバイダーをOpenClawに接続し、APIキーを平文で残さず、ライブテストを行うようエージェントを支援します。
acp-router
394kClaude CodeやCursorなどのコーディングアシスタントに、OpenClaw経由でタスクを渡し、その作業がそのツール内で行われるようエージェントを支援します。
browser-automation
394kログイン、タブ、応答しなくなったページからの復旧を含め、Webページを段階的に操作するようエージェントに教えます。