ソース情報
- リポジトリ
- ag2ai/resource-hub
- ソースの最終更新活動
- 2026年3月19日 04:42
- 検出された SKILL.md の言語
- 英語
- スター
- 4
- フォーク
- 3
インストール方法
デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。
ソースファイルを確認
インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。
メニュー
デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。
インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
直接コマンドでは確認用 Prompt が省略されます。実行前にソースを確認してください。
npx skills add https://github.com/ag2ai/resource-hub --skill agent-patternsコマンドは1行のまま表示されます。コピー前に横へスクロールして全体を確認してください。
ローカルで確認しますか?SkillsMP が現在取得できるファイルをダウンロードできます。
SOC 職業分類に基づく
SKILL.md を表示中
| name | agent-patterns |
| description | Patterns for creating and configuring AG2 agents correctly |
| license | Apache-2.0 |
Always use the LLMConfig context manager. Agents created inside its scope inherit the configuration automatically.
from ag2 import LLMConfig
from ag2.agentchat import AssistantAgent, UserProxyAgent
with LLMConfig(api_type="openai", model="gpt-4o"):
planner = AssistantAgent(
name="planner",
system_message="You are a project planner. Break tasks into steps.",
)
reviewer = AssistantAgent(
name="reviewer",
system_message="You review plans for completeness and correctness.",
)
executor = UserProxyAgent(
name="executor",
human_input_mode="NEVER",
code_execution_config={"work_dir": "workspace"},
)
Agents that do not need an LLM (e.g., pure code executors) should be created outside the context manager.
# Good
system_message = (
"You are a SQL analyst. Write SQL queries to answer user questions. "
"Only use SELECT statements. Never modify data."
)
# Bad -- too vague
system_message = "You are a helpful assistant."
data_analyst, code_reviewer.assistant or agent1.Register tools on the agents that should be able to call and execute them:
from ag2.tools import tool
@tool
def search_database(query: str, limit: int = 10) -> str:
"""Search the database and return matching rows."""
# implementation
return results
analyst = AssistantAgent(name="analyst", system_message="...")
executor = UserProxyAgent(name="executor", human_input_mode="NEVER")
# Register: analyst decides when to call, executor runs the function
analyst.register_tool(search_database, caller=analyst, executor=executor)
"ALWAYS" -- Ask for human input on every turn."TERMINATE" -- Ask only when the agent wants to terminate."NEVER" -- Fully autonomous, no human input.# Autonomous executor
executor = UserProxyAgent(name="executor", human_input_mode="NEVER")
# Human-in-the-loop
user = UserProxyAgent(name="user", human_input_mode="TERMINATE")
Agents stop when a reply contains "TERMINATE". Configure this in the system message:
system_message = (
"You solve math problems. When you have the final answer, "
"reply with TERMINATE."
)