Communityコーディング&開発github.com

bdi-mental-states

外部RDFコンテキストをBDI(信念、欲求、意図)に変換し、エージェントの心的状態をモデリングするスキルです。

bdi-mental-states とは?

このスキルは、BDI(信念、欲求、意図)オントロジーに基づいて、エージェントの心的状態を形式的にモデリングするためのものです。外部のRDFコンテキストをエージェントの信念に変換し、認知アーキテクチャを通じて推論を可能にします。主な特徴として、世界状態へのグラウンディング、T2B2T(Triples-to-Beliefs-to-Triples)パイプラインによる双方向変換、認知的連鎖パターンによる動機と実行の追跡、時間的次元管理による信念の有効性チェック、そして説明可能性のための正当化(Justification)の付与が含まれます。SEMAS、JADE、JADEXなどのBDIフレームワークやLogic Augmented Generation(LAG)と統合可能で、RDF/OWL、SPARQL、UML、ArchiMateなどの表記法を抽象度に応じて使い分けます。このスキルは、マルチエージェントシステムにおける説明可能なエージェンシー、セマンティック相互運用性、および遡及的推論を必要とする開発者やAIエージェントユーザーにとって有用です。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main/skills/bdi-mental-states

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

BDI心的状態モデリング

外部RDFコンテキストを、形式的なBDIオントロジーパターンを使用してエージェントの心的状態(信念、欲求、意図)に変換します。このスキルにより、エージェントは認知アーキテクチャを通じてコンテキストを推論し、熟考的推論、説明可能性、マルチエージェントシステム内でのセマンティック相互運用性をサポートできるようになります。

アクティベーション条件

以下の場合にこのスキルをアクティベートしてください:

  • 外部RDFコンテキストを世界状態に関するエージェントの信念に処理する場合
  • 知覚、熟考、行動のサイクルを持つ合理的エージェンシーをモデリングする場合
  • トレース可能な推論チェーンを通じて説明可能性を実現する場合
  • BDIフレームワーク(SEMAS、JADE、JADEX)を実装する場合
  • LLMに形式的な認知構造を追加する場合(論理拡張生成)
  • マルチエージェントプラットフォーム間で心的状態を調整する場合
  • 信念、欲求、意図の時間的進化を追跡する場合
  • 動機付け状態を行動計画にリンクする場合

以下の隣接作業については、他のスキルに属するためアクティベートしないでください:

  • 一般的なコンテキストウィンドウの説明や注意機構:context-fundamentals
  • 形式的なBDI状態を持たない永続的なユーザー、エンティティ、会話メモリ:memory-systems
  • スーパーバイザー、スウォーム、ハンドオフのトポロジー決定:multi-agent-patterns
  • 一般的なエージェント評価基準や品質ゲート:evaluation

コアコンセプト

心的現実アーキテクチャ

心的状態を2つの存在論的カテゴリに分離します。なぜなら、BDI推論には「何が持続するか」と「何が起こるか」の区別が必要だからです:

心的状態(持続者) -- これらを時間間隔にわたって保持される持続的な認知属性としてモデル化します:

  • Belief(信念): エージェントが世界について真であると保持するものを表します。すべての信念を世界状態参照に基づかせてください。
  • Desire(欲求): エージェントが実現したいと願うものを表します。各欲求を、それを動機付ける信念にリンクしてください。
  • Intention(意図): エージェントが達成することにコミットするものを表します。意図は欲求を充足し、計画を指定する必要があります。

心的プロセス(継続者) -- これらを心的状態を作成または変更するイベントとしてモデル化します。なぜなら、因果的遷移を追跡することで説明可能性が実現されるからです:

  • BeliefProcess(信念プロセス): 知覚から信念の形成/更新をトリガーします。常に生成元の世界状態に接続してください。
  • DesireProcess(欲求プロセス): 既存の信念から欲求を生成します。動機付けの連鎖を保持します。
  • IntentionProcess(意図プロセス): 選択された欲求を実行可能な意図としてコミットします。

認知的連鎖パターン

信念、欲求、意図を、双方向プロパティ(motivates/isMotivatedBy、fulfills/isFulfilledBy)を使用して有向チェーンに配線します。これにより、前方推論(エージェントは何をすべきか?)と後方トレース(エージェントはなぜ行動したか?)の両方が可能になります:

:Belief_store_open a bdi:Belief ;
    rdfs:comment "店は開いている" ;
    bdi:motivates :Desire_buy_groceries .

:Desire_buy_groceries a bdi:Desire ;
    rdfs:comment "私は食料品を買いたい" ;
    bdi:isMotivatedBy :Belief_store_open .

:Intention_go_shopping a bdi:Intention ;
    rdfs:comment "私は食料品を買いに行く" ;
    bdi:fulfills :Desire_buy_groceries ;
    bdi:isSupportedBy :Belief_store_open ;
    bdi:specifies :Plan_shopping .

世界状態グラウンディング

常に心的状態を自由文による説明ではなく世界状態参照に基づかせてください。なぜなら、グラウンディングされていない信念はセマンティッククエリとエージェント間相互運用性を損なうからです:

:Agent_A a bdi:Agent ;
    bdi:perceives :WorldState_WS1 ;
    bdi:hasMentalState :Belief_B1 .

:WorldState_WS1 a bdi:WorldState ;
    rdfs:comment "会議は午前10時に部屋5で予定されている" ;
    bdi:atTime :TimeInstant_10am .

:Belief_B1 a bdi:Belief ;
    bdi:refersTo :WorldState_WS1 .

目標指向型計画

bdi:specifiesを使用して意図を計画に接続し、bdi:precedesを使用して計画を順序付けられたタスクシーケンスに分解します。この分離により、実行順序を明示的に保ちながら、異なる意図間で計画を再利用できます:

:Intention_I1 bdi:specifies :Plan_P1 .

:Plan_P1 a bdi:Plan ;
    bdi:addresses :Goal_G1 ;
    bdi:beginsWith :Task_T1 ;
    bdi:endsWith :Task_T3 .

:Task_T1 bdi:precedes :Task_T2 .
:Task_T2 bdi:precedes :Task_T3 .

T2B2Tパラダイム

Triples-to-Beliefs-to-Triplesを双方向パイプラインとして実装します。なぜなら、エージェントは外部RDFコンテキストを消費すると同時に、新しいRDFアサーションを生成する必要があるからです。すべてのT2B2T実装を2つの明示的なフェーズで構造化します:

フェーズ1: Triples-to-Beliefs -- 受信したRDFトリプルを信念インスタンスに変換します。bdi:triggersを使用して外部世界状態をBeliefProcessに接続し、bdi:generatesを使用して結果として生じる信念を生成します。これにより、ソースデータから内部認知に至るまでの来歴が保持されます:

:WorldState_notification a bdi:WorldState ;
    rdfs:comment "プッシュ通知:支払いリクエスト $250" ;
    bdi:triggers :BeliefProcess_BP1 .

:BeliefProcess_BP1 a bdi:BeliefProcess ;
    bdi:generates :Belief_payment_request .

フェーズ2: Beliefs-to-Triples -- BDI熟考が意図を選択して計画を実行した後、bdi:bringsAboutを使用して結果をRDFに投影します。これによりループが閉じられ、ダウンストリームシステムがエージェントの出力を標準的なリンクトデータとして消費できるようになります:

:Intention_pay a bdi:Intention ;
    bdi:specifies :Plan_payment .

:PlanExecution_PE1 a bdi:PlanExecution ;
    bdi:satisfies :Plan_payment ;
    bdi:bringsAbout :WorldState_payment_complete .

抽象度に応じた表記法の選択

モデリングするC4抽象度レベルに基づいて表記法を選択します。なぜなら、間違ったレベルで表記法を混在させると、認知アーキテクチャが明確になるどころか曖昧になるからです:

C4レベル表記法心的状態の表現
L1 コンテキストArchiMateエージェント境界、外部知覚ソース
L2 コンテナArchiMateBDI推論エンジン、信念ストア、計画実行器
L3 コンポーネントUML心的状態マネージャー、プロセスハンドラー
L4 コードUML/RDFBelief/Desire/Intentionクラス、オントロジーインスタンス

正当化と説明可能性

bdi:isJustifiedByを使用して、すべての心的エンティティにbdi:Justificationインスタンスをアタッチします。なぜなら、正当化されていない心的状態はエージェントの推論を不透明で追跡不可能にするからです。各正当化は、心的状態を生み出した証拠やルールをキャプチャする必要があります:

:Belief_B1 a bdi:Belief ;
    bdi:isJustifiedBy :Justification_J1 .

:Justification_J1 a bdi:Justification ;
    rdfs:comment "公式発表がメールで受信された" .

:Intention_I1 a bdi:Intention ;
    bdi:isJustifiedBy :Justification_J2 .

:Justification_J2 a bdi:Justification ;
    rdfs:comment "場所の前提条件が満たされた" .

時間的次元

bdi:hasValidityとTimeIntervalインスタンスを使用して、すべての心的状態に有効期間を割り当てます。なぜなら、時間的束縛のない信念は、共時推論中にガベージコレクションや競合チェックができないからです:

:Belief_B1 a bdi:Belief ;
    bdi:hasValidity :TimeInterval_TI1 .

:TimeInterval_TI1 a bdi:TimeInterval ;
    bdi:hasStartTime :TimeInstant_9am ;
    bdi:hasEndTime :TimeInstant_11am .

SPARQL時間フィルタを使用して、特定の時点でアクティブな心的状態を問い合わせます。このパターンを使用して、同じ世界状態に関する複数の信念が時間的に重なる場合の競合を解決します:

SELECT ?mentalState WHERE {
    ?mentalState bdi:hasValidity ?interval .
    ?interval bdi:hasStartTime ?start ;
              bdi:hasEndTime ?end .
    FILTER(?start <= "2025-01-04T10:00:00"^^xsd:dateTime &&
           ?end >= "2025-01-04T10:00:00"^^xsd:dateTime)
}

合成的心エンティティ

bdi:hasPart関係を使用して複雑な信念を構成部分に分解します。なぜなら、モノリシックな信念は部分的な更新時に完全な置き換えを強制するからです。各サブ信念が独立して更新、クエリ、または無効化できるように、複合信念を構造化します:

:Belief_meeting a bdi:Belief ;
    rdfs:comment "午前10時に部屋5で会議" ;
    bdi:hasPart :Belief_meeting_time , :Belief_meeting_location .

# 時間に影響を与えずに場所コンポーネントのみを更新
:BeliefProcess_update a bdi:BeliefProcess ;
    bdi:modifies :Belief_meeting_location .

実践ガイダンス

6つのパスでBDIモデルを構築する

外部セマンティックコンテキストをBDI表現に変換する際に、このワークフローを使用します:

  1. 世界状態基盤を定義する: エージェントが知覚できる外部の事実やイベントを特定します。信念を作成する前に、これらを世界状態としてモデル化します。
  2. 信念インスタンスを作成する: 関連する各世界状態を、来歴、時間的有効性、正当化参照を含む信念に変換します。
  3. 信念から欲求を導出する: 信念が目標関連の動機を生み出す場合にのみ、欲求を追加します。各欲求を、それを動機付ける信念にリンクします。
  4. 意図を意図的にコミットする: エージェントが計画にコミットする場合にのみ、欲求を意図に昇格させます。選択された計画と前提条件を記録します。
  5. アクション結果をトリプルに投影する: 実行後、結果として生じる世界状態をRDFとして出力し、ダウンストリームシステムが新しい状態を消費できるようにします。
  6. コンピテンシークエスチョンで検証する: モデルを信頼する前に、来歴、動機、計画シーケンス、アクティブな有効期間をクエリします。

オントロジーを小さく保つ

Agent、WorldState、Belief、Desire、Intention、Plan、Task、Justification、TimeIntervalから始めます。コンピテンシークエスチョンがコアモデルが必要なクエリに答えられないことが証明された場合にのみ、特殊化されたクラスを追加します。コンパクトなオントロジーはプロンプトへのシリアライズが容易で、検証が容易で、脆い推論チェーンを作成する可能性が低くなります。

心的状態のセマンティクスが重要である場合にのみBDIを使用する

BDIモデリングは、システムが説明可能なエージェンシーを必要とする場合に正当化されます:なぜエージェントが何かを信じたか、その信念がどのような欲求を生み出したか、どの意図が選択されたか、どの計画が実行されたか。システムが単にセッション間で事実を記憶するだけでよい場合はmemory-systemsを使用します。単にエージェント間で作業を分割するだけでよい場合はmulti-agent-patternsを使用します。

詳細トピック

統合パターン

論理拡張生成(LAG)

LAGを使用してLLMの出力をオントロジー構造で制約します。なぜなら、制約のない生成はBDIクラス制約に違反するトリプルを生成するからです。オントロジーをプロンプトコンテキストにシリアライズし、生成されたトリプルを受け入れる前にそれに対して検証します:

def augment_llm_with_bdi_ontology(prompt, ontology_graph):
    ontology_context = serialize_ontology(ontology_graph, format='turtle')
    augmented_prompt = f"{ontology_context}\n\n{prompt}"

    response = llm.generate(augmented_prompt)
    triples = extract_rdf_triples(response)

    is_consistent = validate_triples(triples, ontology_graph)
    return triples if is_consistent else retry_with_feedback()

SEMASルール変換

ルールベースのエージェントプラットフォームにデプロイする場合、BDIオントロジーパターンを実行可能なプロダクションルールに変換します。各認知チェーンリンク(信念から欲求、欲求から意図)をHEAD/CONDITIONALS/TAILルールにマッピングします。これにより、ランタイム実行を可能にしながら熟考的セマンティクスが保持されます:

% 信念が欲求形成をトリガー
[HEAD: belief(agent_a, store_open)] /
[CONDITIONALS: time(weekday_afternoon)] »
[TAIL: generate_desire(agent_a, buy_groceries)].

% 欲求が意図コミットメントをトリガー
[HEAD: desire(agent_a, buy_groceries)] /
[CONDITIONALS: belief(agent_a, has_shopping_list)] »
[TAIL: commit_intention(agent_a, buy_groceries)].

ガイドライン

  1. 世界状態をエージェントの視点から独立した構成としてモデル化し、心的状態のための参照基盤を提供します。

  2. 持続者(永続的な心的状態)と継続者(一時的な心的プロセス)を区別し、DOLCEオントロジーに準拠します。

  3. 目標を心的状態ではなく記述として扱い、認知層と計画層の分離を維持します。

  4. hasPart関係をメロニミック構造に使用し、選択的な信念更新を可能にします。

  5. atTimeまたはhasValidityを介して、すべての心的エンティティを時間的構成要素に関連付けます。

  6. 双方向プロパティペア(motivates/isMotivatedBy、generates/isGeneratedBy)を柔軟なクエリに使用します。

  7. 心的エンティティをJustificationインスタンスにリンクし、説明可能性と信頼性を確保します。

  8. T2B2Tを実装するには:(1)RDFを信念に変換し、(2)BDI推論を実行し、(3)心的状態をRDFに投影します。

  9. 心的プロセスに対する存在制約を定義します(例:BeliefProcess ⊑ ∃generates.Belief)。

  10. 相互運用性のために、確立されたODP(EventCore、Situation、TimeIndexedSituation、BasicPlan、Provenance)を再利用します。

コンピテンシークエスチョン

以下のSPARQLクエリに対して実装を検証します:

# CQ1: 特定の欲求の形成を動機付けた信念はどれか?
SELECT ?belief WHERE {
    :Desire_D1 bdi:isMotivatedBy ?belief .
}

# CQ2: 特定の意図はどの欲求を充足するか?
SELECT ?desire WHERE {
    :Intention_I1 bdi:fulfills ?desire .
}

# CQ3: どの心的プロセスが信念を生成したか?
SELECT ?process WHERE {
    ?process bdi:generates :Belief_B1 .
}

# CQ4: 計画内のタスクの順序付けられたシーケンスは?
SELECT ?task ?nextTask WHERE {
    :Plan_P1 bdi:hasComponent ?task .
    OPTIONAL { ?task bdi:precedes ?nextTask }
} ORDER BY ?task

例

例1: RDF通知からBDIチェーンへ

入力世界状態:

:WorldState_invoice_due a bdi:WorldState ;
    rdfs:comment "請求書INV-42の支払い期限は明日です" ;
    bdi:atTime :Time_2026_05_15 .

BDI投影:

:Belief_invoice_due a bdi:Belief ;
    bdi:refersTo :WorldState_invoice_due ;
    bdi:isJustifiedBy :Justification_billing_system ;
    bdi:motivates :Desire_avoid_late_fee .

:Desire_avoid_late_fee a bdi:Desire ;
    bdi:isMotivatedBy :Belief_invoice_due .

:Intention_pay_invoice a bdi:Intention ;
    bdi:fulfills :Desire_avoid_late_fee ;
    bdi:specifies :Plan_pay_invoice .

例2: 境界判断

タスクが「アリスは簡潔な要約を好むことを記憶する」である場合、memory-systemsを使用します。タスクが「なぜエージェントがアリスは簡潔な要約を好むと信じているか、その信念がどのような欲求を動機付け、どのような意図にコミットしたか」を表現する場合、このスキル(bdi-mental-states)を使用します。

Individual skills in this repo

This repo contains 19 individual skills — each has its own dedicated page.

advanced-evaluation

This skill should be used for advanced LLM evaluation: LLM-as-judge systems, direct scoring, pairwise comparison, rubric calibration, evaluator bias mitigation, confidence scoring, and automated quality assessment.

book-sft-pipeline

This skill should be used for book-to-SFT pipelines: ePub extraction, literary segmentation, author-voice dataset construction, style-transfer training, LoRA workflows, and model evaluation for voice replication.

comprehensive-research-agent

Ensure thorough validation, error recovery, and transparent reasoning in research tasks with multiple tool calls

context-compression

This skill should be used when long-running agent sessions need context compression, structured summarization, compaction, token-per-task optimization, or durable handoff summaries that preserve decisions, files, risks, and next actions.

context-degradation

This skill should be used for diagnosing and mitigating context degradation: lost-in-middle failures, context poisoning, context clash, context confusion, attention-pattern issues, and agent performance degradation caused by accumulated or conflicting context.

context-fundamentals

This skill should be used to explain or reason about the foundational concepts of context engineering: what context is, the anatomy of a context window, how attention mechanics work, the U-shaped attention curve, why context quality matters more than quantity, and the mental models needed to interpret every other context-engineering decision. Use this for conceptual explanation, onboarding, and background reading. Route operational work to the specialized skills: debugging attention failures goes to context-degradation, token-efficiency work goes to context-optimization, conversation summarization goes to context-compression, and project-shape decisions go to project-development.

context-optimization

This skill should be used for improving context efficiency: context budgeting, observation masking, prefix or KV-cache strategy, partitioning, token-cost reduction, retrieval scoping, and extending effective context capacity without lowering answer quality.

evaluation

This skill should be used when building agent evaluation systems: deterministic checks, regression suites, multi-dimensional rubrics, quality gates, production monitoring, baseline comparison, and outcome measurement for agent pipelines.

filesystem-context

This skill should be used when agent work needs file-backed context: durable scratchpads, tool-output offloading, just-in-time discovery, cross-agent handoff files, filesystem memory, or cleanup policies for context stored outside the prompt.

harness-engineering

This skill should be used when designing autonomous agent harnesses: research loops, evaluation scaffolds, locked and editable surfaces, durable logs, novelty gates, pruning, rollback, PR preparation, and human approval boundaries.

hosted-agents

This skill should be used when designing hosted or background agent infrastructure: sandboxed execution, remote coding environments, warm pools, session persistence, multiplayer collaboration, self-spawning agents, or Modal-style sandboxes.

latent-briefing

This skill should be used when the user asks to "share memory between agents", "KV cache compaction for multi-agent", "orchestrator worker context", "latent briefing", "reduce worker tokens", "cross-agent memory without summarization", or discusses Attention Matching compaction, recursive language models with workers, or token explosion in hierarchical agents.

long-horizon-prompting

This skill should be used when writing, enhancing, or evaluating the launch prompt for a long-running autonomous agent or a parallel multi-agent orchestration attacking a hard problem: pseudo-formal task briefs that define terms and an exact success predicate linguistically, enumerate non-counting outcomes, set persistence rules with explicit stop and return conditions and effort floors, manage a diverse portfolio of parallel approaches with an approach registry and blocked-route bookkeeping, and gate the return on adversarial audit. Route agent topology and coordination protocols to multi-agent-patterns, runtime control surfaces and loop governance to harness-engineering, evaluator and quality-gate construction to evaluation, judge design to advanced-evaluation, and compaction or memory mechanics to context-compression and memory-systems.

memory-systems

This skill should be used for persistent semantic memory in agent systems: cross-session knowledge retention, entity tracking, temporal validity, graph or vector retrieval, memory consolidation, and memory benchmark selection. Route file-backed scratchpads to filesystem-context, handoff summaries to context-compression, and token-efficiency tactics to context-optimization.

multi-agent-patterns

This skill should be used when designing multi-agent systems that need context isolation, supervisor or swarm coordination, explicit handoffs, parallel execution, or a decision on whether multiple agents are justified.

project-development

This skill should be used for project-level decisions about LLM-powered systems: whether an LLM is the right primitive for the task at hand, the shape of a multi-stage batch or agent pipeline, token and cost estimation, choosing between single-agent and multi-agent at the project level, structured output design for downstream parsing, and structuring agent-assisted iteration. Use this when the unit of work is a whole project or a multi-stage pipeline. Route individual tool design to tool-design and individual skill-loading or context-budget tactics to context-optimization.

self-improvement-loops

This skill should be used when the harness, scaffold, workflow, or optimizer itself is the optimization target: recursive self-improvement (RSI) loops, meta-harnesses, self-improving harnesses that mine their own failures and propose bounded edits, evolutionary or population-based search over agent scaffolds, acceptance gates for self-modifying systems, and agentic context evolution where the mechanism that produces context is versioned and evolved. Route governance of a single autonomous loop (locked surfaces, durable logs, rollback, novelty gates, approval boundaries) to harness-engineering, measurement and quality-gate design to evaluation, judge design to advanced-evaluation, and remote sandbox infrastructure to hosted-agents.

self-managed-context

This skill should be used when a model gets read-write control over its own live context window instead of a harness-scheduled compaction policy: the context exposed as an editable file the model rewrites with code tools, model-driven eviction and in-place updates, the harness invariants that keep self-editing safe (pinned prefix, edit gate, edit receipts, budget readouts, rollback on overflow), the prefix-cache cost of mid-context edits, and steering or training the model's own context-editing strategy. Route note content and fixed-threshold summarization to context-compression, cache-stable layout under harness control to context-optimization, file offloading to filesystem-context, and loop governance to self-improvement-loops.

tool-design

This skill should be used for the tool-interface layer of an agent system specifically: writing tool descriptions agents can route on, designing tool schemas and response formats, naming conventions, actionable error recovery messages, MCP server design, tool-set consolidation, and deciding when to add or remove an individual tool. Use this when the unit of work is a single tool or a set of tools. Route project-shape, pipeline architecture, and task-model-fit decisions to project-development; route deciding whether to introduce sub-agents to multi-agent-patterns.

関連スキル