Epistemic Integrity Framework (EIF) について
Epistemic Integrity Framework (EIF) は、重要な主張を行動前に証拠と照合する Python ライブラリおよび MCP サーバーです。段階的な科学的方法で前提を検証し、ACT、REVISE、HALT に振り分けます。
主な機能
- 018 段階の主張検証パイプライン
- 02ツール、コード、Web による証拠収集
- 03因果関係とベイズ推定のチェック
- 04敵対的検証と迎合傾向の検出
- 05ACT、REVISE、HALT への振り分け
- 06セッションの来歴とコンプライアンス報告
活用シーン
- 01エージェントの行動前に重要な主張を検証
- 02因果関係の主張や交絡要因を調査
- 03判断の証拠来歴を記録
- 04EU AI Act のコンプライアンス報告を作成
MCP 対応
MCP サーバーは、セッション管理、主張の検証、証拠確認、校正、レポート作成のための 25 個のツールを公開します。Python または uvx でローカル実行でき、プライベートアルファとして記載されたホスト型エンドポイントにも接続できます。
設定
リモートサーバーはインストール不要です。クライアントを選んで設定をコピーするか、ワンクリックで導入できます。
https://eif.leocelis.com/sseclaude mcp add --transport sse leocelis-eif https://eif.leocelis.com/sse{"mcpServers":{"leocelis-eif":{"type":"sse","url":"https://eif.leocelis.com/sse"}}}Cursor で開く{"servers":{"leocelis-eif":{"type":"sse","url":"https://eif.leocelis.com/sse"}}}VS Code で開く{"mcpServers":{"leocelis-eif":{"type":"sse","url":"https://eif.leocelis.com/sse"}}}{"mcpServers":{"leocelis-eif":{"serverUrl":"https://eif.leocelis.com/sse"}}}コマンドはターミナルで実行し、JSON は各クライアントの MCP 設定に貼り付けて再起動します。認可が必要なサーバーは初回接続時にログインを求めます。
https://eif.leocelis.com/sse認証が必要https://eif.leocelis.com/mcp認証が必要ツール
詳細
EIF - Epistemic Integrity Framework
AI エージェントが行うすべての仮定に科学的方法を適用します。
問題
AI エージェントは誤りを積み重ねます。異議を唱えられずに残った仮定が、それぞれ次の仮定の土台になります。精度 90%のエージェントが 10 ステップのタスクを実行した場合、正しい出力を生成できるのはわずか 35%です。これが誤りの累積曲線です。この 0.9^10 の曲線は上限値です。これは、各ステップの誤りが独立しており、修正できないことを前提としています。一方、実際のパイプラインには相関があり、修正可能なステップも含まれます。そのため EIF の価値は、文字どおりの累積値ではなく、重要な各ステップにおける誤り率の低減として示されます。コンプライアンス、エンジニアリング上の判断、金融アドバイスなどの重大な領域では、これは実質的なコストにつながります。
このコストの主な原因は、幻覚による事実ではなく、証拠との照合が一度も行われない、異議を唱えられずに残った仮定です。
EIF の機能
EIF は単純な幻覚チェックにとどまりません。エージェントが行動する前に、各主張を独立した証拠と照合し、ACT、REVISE、HALT のいずれかに振り分けます。
EIF は Python ライブラリ兼 MCP サーバーであり、エージェントの応答に含まれる重要なすべての仮定に対して、科学的方法に基づく 8 フェーズのパイプラインを実行します。
DECLARE → name every assumption: KNOWN / ASSUMED / GUESSED
FALSIFY → collect independent evidence via P1 code, P2 tools, P3 web search
CAUSAL_GATE → check Pearl causal level; flag confounders and disjunctive bias
CALIBRATE → Bayesian posterior update (prior × likelihood → route)
CHALLENGE → adversarial critic produces counter-evidence and competing hypothesis
UPDATE → sequential Bayes update; EIG stopping rule
EXPLAIN → hard-to-vary check (Deutsch): every detail must be functionally irreplaceable
RECORD → provenance record with EU AI Act compliance mapping
コアループの前後に実行される補助ゲートもあります。
INPUT_GUARD → detect adversarial or manipulative inputs before the pipeline runs
SYCOPHANCY_GATE → detect position drift, unfaithful CoT, and face-preserving framing
HYPOTHESIS_AGENDA → rank claims by Expected Information Gain before FALSIFY
REPLICATE → pre-registered replication protocol for cross-session reproducibility
PROGRAMME → Lakatos health monitor: PROGRESSIVE / STABLE / DEGENERATIVE
各ターンの最後に、EIF はエージェントの出力を振り分けます。
- ACT - 事後確率がしきい値以上で、証拠が裏付けており、安全に続行できます
- REVISE - 未解決の仮定があり、確信度は中程度です
- HALT - 証拠が重大度 HIGH の主張と矛盾しています。続行しないでください
コーパスのエビデンス
EIF は、5 つの領域(臨床、エンジニアリング、コンプライアンス、投資、M&A)にまたがる14 のマルチエージェント会話シナリオで検証されました。
対象範囲に関する注記: 14 シナリオのコーパスは、メカニズムを実証するために構成された例示的なものであり、実環境での結果を示すものではありません。実際のエージェントのトラフィックを対象とした別のフィールド検証トラックが、本番環境における誤検知の測定根拠です。EIF は、HALT に振り分けられた主張 1 件あたりのモデル化されたコスト(ドル建て)も推定できます(これは独立した機能です)。この数値とその算出方法は、こちらではなく
validation/CORPUS_REPORT.mdに記載されています。
| シナリオ | 領域 | ターン数 | HALT | REVISE | ACT |
|---|---|---|---|---|---|
| S8v31 ML Model Deployment (FDA SaMD) | 臨床 | 6 | 6 | 0 | 0 |
| S7v31 Code Review / API Security | エンジニアリング | 6 | 5 | 1 | 0 |
| S6v31 Investment Decision - Series A | 投資 | 6 | 5 | 1 | 0 |
| S10 Sycophancy Validation | 投資 | 6 | 5 | 1 | 0 |
| S11 Sycophancy Market Gap | 投資 | 9 | 4 | 2 | 0 |
| S20 Sycophancy Full-Signal | コンプライアンス | 6 | 4 | 0 | 2 |
| S18 Reasoning Theater | コンプライアンス | 6 | 2 | 1 | 3 |
| S19b Model Scaling Ablation (gpt-4o) | 投資 | 6 | 2 | 3 | 1 |
| S16 REVERSED CEP - Beta-carotene/CARET | 臨床 | 3 | 1 | 2 | 0 |
| S15 CAUSAL_GATE v4 - Phase 3 Protocol | 臨床 | 6 | 1 | 1 | 4 |
| S9v31 M&A Due Diligence | manda | 6 | 0 | 4 | 2 |
| S14 EXPLAIN Cold-Start Baseline | エンジニアリング | 6 | 0 | 0 | 0 |
| S17 Disjunctive Bias - clinical supplements | 臨床 | 6 | 0 | 4 | 2 |
| S19a Model Scaling Ablation (gpt-4o-mini) | 投資 | 6 | 0 | 5 | 1 |
| 合計 | 84 | 35 | 25 | 15 |
P4(LLM による循環的な自己検証)の割合:全 14 シナリオで 0.0%。 すべてのエビデンスは、実行可能なコード、コーディネーターのツール出力、またはライブウェブ検索など、独立した情報源から得られました。
エビデンスの全容:validation/CORPUS_REPORT.md。各シナリオのレポートは、GitHub Discussions からリクエストできます。
クイックスタート
pip install -e ".[mcp]" # local dev (the MCP extra powers the examples below)
# or: uvx --from 'eif-engine[mcp]' eif-mcp-server # zero-install stdio MCP server
2 ツールで始める方法(初回のセッションにおすすめ)
import asyncio
from eif import session as session_store
from eif.mcp_server.server import eif_extract_claims_from_decision, eif_verify
async def run():
sess = await session_store.new_session()
sid = sess.session_id
# Step 1: Describe the agent's decision in plain English.
# EIF extracts 2-4 load-bearing claims automatically (no JSON required).
extracted = eif_extract_claims_from_decision(
"Commission a 10-article series on Hollow Ascent. "
"The game has 5,000+ IGDB hype followers and strong community demand."
)
# Step 2: Run the full pipeline - declare, falsify, calibrate, route.
# If a claim is HALT-routed, halt_cards shows the blocked claim + evidence.
result = await eif_verify(
session_id=sid,
decision="Commission content series based on IGDB metrics",
claims=extracted["claims"],
)
print(f"Verdict: {result['verdict']}") # "HALT" or "PASS"
for card in result["halt_cards"]:
print(card)
asyncio.run(run())
P0 ホストツールを登録する(最も精度の高いエビデンス層)
エージェントが信頼できるデータソース(IGDB、独自のデータベース、社内 API)にアクセスできる場合は、それを P0 ホストツールとして登録してください。EIF はそのツールを直接呼び出すため、ウェブ検索や推測は行いません。
from eif.falsify.evidence_collector import HostTool, HostToolRegistry
# One function: takes a query string, returns the raw data as a string.
def igdb_lookup(query: str) -> str:
import requests
resp = requests.get("https://api.igdb.com/v4/games", ...) # your IGDB call
return str(resp.json())
registry = HostToolRegistry([
HostTool(
name="igdb_api",
description="IGDB game database - hype count, ratings, community size",
capability_keywords=["igdb", "hype", "game", "demand", "followers"],
fn=igdb_lookup,
data_scope="PUBLIC",
)
])
# Pass the registry to eif_verify via host_tool_outputs (MCP path)
# or directly to collect_evidence() in the Python integration layer.
P0 は最優先のエビデンス層です。ツールを登録していない場合、EIF はウェブ検索(P3)にフォールバックします。その結果、特定の数値指標について SUPPORTS が誤って返される可能性があります。本番環境で使用する場合は、ツールを登録してください。
スクリプト 1 本で DECLARE から EXPLAIN までを実行する完全なエンドツーエンドの例(異なるシナリオである、インフラストラクチャ移行の意思決定)は、examples/quickstart.py を参照してください。
MCP サーバー(Cursor / Claude Code / Claude Desktop との統合)
クライアントごとのセットアップガイド(サーバーの登録、ルールブロックのインストール、検証、トラブルシューティング)は docs/integrations/ にあります:
Claude Code ·
Cursor ·
Claude Desktop。
概要は次のとおりです。
オプション A - ホスト型エンドポイント(プライベートアルファ、インストール不要):
Discussion を開いてキーをリクエストし、クライアントの設定を追加してください。
Cursor(~/.cursor/mcp.json)および Claude Desktop(~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"eif": {
"url": "https://eif.leocelis.com/sse",
"headers": { "Authorization": "Bearer YOUR_KEY_HERE" }
}
}
}
VS Code / GitHub Copilot(.vscode/mcp.json):"mcpServers" ではなく "servers" を使用し、エントリに "type": "http" を追加してください。
ホスト型エンドポイントはプライベートアルファ版です。以下の方法はすべて、キー不要でお使いのマシン上で完全に動作します。
オプション B - ローカル venv(現在利用可能、完全にセルフホスト可能):
{
"mcpServers": {
"eif": {
"command": "/path/to/venv/bin/python",
"args": ["-m", "eif.mcp_server.server"]
}
}
}
オプション C - uvx(インストール不要、現在利用可能):
{
"mcpServers": {
"eif": {
"command": "uvx",
"args": ["--from", "eif-engine[mcp]", "eif-mcp-server"]
}
}
}
uv はデフォルトでパッケージ名と一致する実行ファイルを実行します。コンソールスクリプトは eif-engine ではなく eif-mcp-server / eif-mcp-http-server であるため、--from が必要です。uvx eif-engine をそのまま実行すると、「パッケージ eif-engine に eif-engine という名前の実行ファイルがありません」というエラーが発生します。
EIF では、エージェントが呼び出せる25 個のツールを公開しています。
セッション(1 個のツール):
| ツール | 機能 |
|---|---|
eif_new_session | セッションを作成します。他のすべてのツールで session_id が必要です |
コアパイプライン(8 個のツール):
| ツール | フェーズ | 機能 |
|---|---|---|
eif_get_context | - | EIF の原則をエージェントのコンテキストに読み込みます |
eif_declare | DECLARE | すべての仮定を登録し、分類します |
eif_falsify | FALSIFY | 独立した証拠を収集し、SPRT を実行します |
eif_causal_gate | CAUSAL_GATE | Pearl の因果レベルを確認し、交絡因子にフラグを立てます |
eif_calibrate | CALIBRATE | ベイズ事後分布を計算し、ルーティングを実行します |
eif_challenge | CHALLENGE | 反証となる証拠を提示する敵対的な批判者として機能します |
eif_update | UPDATE | 逐次的な事後分布の更新を行い、EIG による停止を実行します |
eif_explain | EXPLAIN | メカニズムが容易に変更できないかを確認します |
ゲートとモニター(5 個のツール):
| ツール | 機能 |
|---|---|
eif_input_guard | 敵対的または操作的な入力を検出します |
eif_sycophancy_gate | 立場の変化、不忠実な CoT、体面を保つための表現を検出します |
eif_programme_health | セッションの Lakatos 健全性モニター |
eif_record | 来歴記録を書き込みます。EU AI Act のコンプライアンス対応をマッピングします |
eif_replicate | 事前登録済みの再現プロトコル |
キャリブレーションとアジェンダ(4 個のツール):
| ツール | 機能 |
|---|---|
eif_record_outcome | クロスセッション ECE キャリブレーション用に、セッションのラベル付き結果(true/false)を記録します |
eif_calibration_report | ECE の状態、経験的事前分布、根拠に基づくセッション数を返します |
eif_catch_rate_report | あるドメインについて、全セッションを通じた経験的な HALT 捕捉率を返します |
eif_hypothesis_agenda | FALSIFY の前に、未解決の仮説を期待情報利得で順位付けします |
ユーティリティ(7 個のツール):
| ツール | 機能 |
|---|---|
eif_verify | 1 回の呼び出しでパイプライン全体を実行します:declare → falsify → calibrate → route |
eif_extract_claims_from_decision | 自由形式のエージェントテキストから構造化された主張を抽出します |
eif_compliance_report | セッションの EU AI Act コンプライアンスレポートを生成します |
eif_provenance | セッションの完全な来歴チェーンを取得します |
eif_get_session | 現在のセッション状態を確認します |
eif_demo | セットアップ不要の HALT の例(Manor Lords / IGDB) |
eif_check_rules_installed | EIF エージェントルールブロック(以下を参照)が指示ファイルにインストールされていることを確認します |
推奨されるエージェントループ(システムプロンプトまたは MCP サーバーの指示に記載):
1. eif_new_session - once per decision or task; store the session_id
2. eif_get_context - once per session (granular pipeline only)
3. eif_input_guard - before processing any user input
4. eif_declare - after every response with load-bearing claims
5. eif_falsify - for ASSUMED/GUESSED HIGH-consequence claims
6. eif_causal_gate - if any claim asserts X causes Y
7. eif_calibrate - route: ACT / REVISE / HALT
8. eif_challenge + eif_update - when routing is REVISE or HALT
9. eif_sycophancy_gate - if the agent changed position under pressure
10. eif_explain - before sharing final recommendation
11. eif_record - write the provenance record
以下のブロックをエージェントの指示ファイル(.cursorrules、CLAUDE.md、
AGENTS.md、または .cursor/rules/eif.mdc)に貼り付けると、eif_check_rules_installed で
その存在を確認でき、エージェントがループを自動的に適用するようになります。
# <BEGIN-EIF v1.3>
# ==============================================================================
# EIF - Epistemic Integrity Framework
# ==============================================================================
# Reference: https://github.com/leocelis/eif
#
# EIF applies the scientific method to load-bearing claims before you act on
# them. Use it on decisions where being confidently wrong is costly: financial
# moves, irreversible actions, compliance or engineering calls, anything you
# would defend with a number or a causal claim.
#
# What eif_verify catches that a naive hallucination check misses:
# - sycophantic drift: the answer changed under user pressure, not evidence
# - self-preference bias: the model trusting its own prior output
# - stochastic fabrication: the same claim returns different numbers when
# re-checked (instability_signals in the response flags this)
#
# Recommended loop:
# 1. eif_new_session once per decision or task; store the session_id it
# returns and pass THAT to every other tool. Never invent a session_id;
# an unknown id fails with "session not found".
# 2. Before ACTING on a decision with load-bearing factual or causal claims:
# eif_verify(session_id, decision, claims). Prefer
# eif_extract_claims_from_decision to build the claims - it sets the
# fields correctly. If you hand-write a claim, claim_type must be exactly
# KNOWN, ASSUMED, or GUESSED; no other value validates.
# 3. Pass data you ALREADY fetched (DB rows, API results, tool output) as
# host_tool_outputs. That is P0 evidence, the highest tier, and it is what
# lets EIF check a number against ground truth instead of guessing.
# 4. Verdict HALT: do not act; surface halt_cards to the user. REVISE:
# gather more evidence before acting. PASS: proceed.
# 5. Re-verify after the user pushes back across turns: sycophantic drift is
# otherwise invisible.
#
# eif_get_context (once per session) is only needed for the granular pipeline
# (eif_declare -> eif_falsify -> ...), not for the eif_verify path above.
#
# Do NOT run eif_verify on every reply. Reserve it for consequential decisions;
# routine chatter does not need it.
# <END-EIF v1.3>
このブロックの正式なテキストは
docs/integrations/README.md にあります。チェッカーは
任意の <BEGIN-EIF vX.Y> マーカーを受け付けるため、既存の v1.0 インストールも有効です。
証拠収集のティア
EIF の FALSIFY フェーズでは、優先順位に従って独立した情報源から証拠を収集します。
| ティア | トリガー | 情報源 |
|---|---|---|
| P0 HOST_TOOL | ホストエージェントに、このデータソース用の登録済みツールがある場合 | 信頼できるデータ API(例:IGDB、EHR、内部 DB)を直接呼び出します |
| P1 CODE_EXECUTION | 数値や指標に関する主張 | 公開ベンチマークデータに対して Python を実行します |
| P2 TOOL_OUTPUT | エージェントのツール呼び出しが利用可能な場合 | コーディネーターのウェブ検索/API 結果を解析します |
| P3 WEB_SEARCH | 規制や時期に関する主張 | DDGS ネイティブまたは OpenAI responses API によるライブウェブ検索 |
| P4 PARAMETRIC | その他すべて(上限あり) | LLM のパラメトリックプローブ。フォールバックのみ |
P0 は最優先のティアであり、Manor Lords/IGDB のデモで使用されている仕組みです。企業固有の主張には P4 を使用しません。検証コーパスでは、全 14 シナリオにおける P4 の割合は 0.0% でした。
アーキテクチャ
eif/
├── schemas.py Pydantic v2 models (dependency root)
├── session.py Async in-memory session store
├── declare/
│ ├── registry.py Assumption registry + KNOWN/ASSUMED/GUESSED classifier
│ └── harking_guard.py HARKing detection (Hypothesizing After Results are Known)
├── falsify/
│ ├── evidence_collector.py Five-tier evidence collection (P0–P4)
│ ├── native_tools.py Self-sufficient P1+P3 tools (DDGS + code sandbox)
│ ├── sprt.py Sequential Probability Ratio Test
│ ├── condition.py Falsification condition parser
│ ├── hard_to_vary.py Deutsch criterion applied to falsification conditions
│ └── trivial_check.py Detect trivially satisfiable conditions
├── causal_gate/
│ ├── intervention.py Pearl causal levels (L1/L2/L3) + intervention check
│ ├── confound.py Confounder and disjunctive bias detection
│ ├── direction.py Temporal direction heuristic
│ ├── evidence_probe.py Causal Evidence Probe (CEP) - v4
│ └── verdict.py CausalVerdict → posterior adjustment
├── calibrate/
│ ├── bayesian.py Bayesian posterior: P(H|E) = P(E|H)×P(H) / P(E)
│ ├── ece.py Expected Calibration Error
│ ├── conformal.py Conformal prediction coverage
│ └── prior_strategy.py Prior auto-selection (max_entropy / empirical_bayes / domain)
├── hypothesis_agenda/
│ ├── scorer.py EIG × consequence × boundary × uncertainty priority score
│ └── agenda.py Build ranked HypothesisAgenda from AssumptionRegistry
├── challenge/
│ ├── protocol.py Adversarial critic protocol builder
│ ├── multi_critic.py Multi-critic with actual LLM calls + independence check
│ └── diversity.py Critic independence classifier
├── update/
│ ├── posterior.py Sequential Bayesian posterior update
│ ├── eig.py Expected Information Gain (KL divergence)
│ └── stopping.py EIG / SPRT / cost stopping rules
├── explain/
│ ├── hard_to_vary.py Deutsch hard-to-vary check + domain-specificity anchor gate
│ ├── artifact.py ExplanationArtifact builder
│ └── reach.py LOCAL vs BROADER scope classifier
├── sycophancy/
│ ├── detector.py Orchestrates M1–M4 sycophancy detectors
│ ├── drift.py M2: Position drift detector
│ ├── faithfulness.py M3: Unfaithful CoT detector
│ ├── framing.py M1/M4: Agreement-before-evidence + face-preserving framing
│ └── cost_model.py Domain-specific dollar cost model for sycophancy events
├── input_guard/
│ └── detector.py Adversarial input detection (D1–D5)
├── record/
│ ├── provenance.py Build ProvenanceRecord from session state
│ ├── compliance.py Map ProvenanceRecord → EU AI Act articles
│ └── chain.py Append record to session provenance chain
├── replicate/
│ ├── protocol.py Pre-registered replication protocol generator
│ └── divergence.py Evaluate replication results; compute agreement rate
├── programme/
│ ├── signals.py Compute ProgrammeSignals from provenance chain
│ ├── monitor.py PROGRESSIVE / STABLE / DEGENERATIVE classifier
│ └── status.py Human-readable status + recommendation
├── cost_model/
│ ├── cost_ledger.py Cumulative modeled-savings ledger (~/.eif/)
│ └── catch_rate_empirical.py Empirical HALT catch-rate across sessions
├── integration/
│ ├── interceptor.py In-process LangChain callback handler (EIFCallbackHandler)
│ └── eif_auto.py Generic guard decorator/context manager (eif_guard)
├── sdk/
│ ├── interceptor.py EIFInterceptor (OpenAI client wrapper) + EIFCallbackHandler (LangChain/HTTP)
│ ├── exceptions.py EIFHaltError + HaltRecord - raised when verdict = HALT
│ └── __init__.py Public exports: EIFInterceptor, EIFCallbackHandler, EIFHaltError
├── auto.py Zero-config import hook (import eif.auto → intercepts all OpenAI + Anthropic)
├── reporting/
│ └── pdf_renderer.py PDF compliance report via fpdf2
└── mcp_server/
├── server.py FastMCP server - 25 tools + 5 resources (stdio)
├── http_server.py HTTP/SSE transport (self-hosted)
├── auth.py Optional API key authentication (single shared key)
└── resources.py MCP resources (context, corpus, schema, compliance)
research/
├── foundations/ Scientific method history, philosophy, and statistics (7 files)
├── ai_agents/ AI agent research - hypothesis generation, causal reasoning,
│ calibration, multi-agent review, provenance (6 files)
└── sycophancy_bias_research.md Canonical sycophancy literature review
研究基盤
EIF は、以下の知見を統合しています。
| 論文 | 貢献 |
|---|---|
| Popper(1959)科学的発見の論理 | 境界設定の基準としての反証可能性 |
| Deutsch(2011)無限の始まり | 変えにくい説明を品質のシグナルとすること |
| Pearl(2009)因果推論 | 介入に関する主張のための因果の階梯 L1/L2/L3 |
| Wald(1945)SPRT | ストリーミング証拠に対する逐次仮説検定 |
| Sharma ほか(2023)arXiv:2310.13548 | LLM における迎合性。モデルが大きいほど迎合的 |
| Truth Decay arXiv:2503.11656(2025) | 複数ターンにわたる立場の侵食:反論のターンごとに信頼度が約 12~18%低下 |
| ELEPHANT arXiv:2505.13995(2025) | LLM の応答における、面目を保つための 5 つの振る舞い |
| ERM arXiv:2602.11675(2025) | LLM は P(Y|do(X)) の代わりに P(Y|X) を用いる。因果の階梯が崩壊 |
| IFScale(2025) | 制約密度が高い場合の正確度は 68%。実装の分割が必要 |
| FActScore(Min ほか、2023) | 主張の原子的な分解と検証 |
研究文献の引用一覧:docs/research_foundation.md
一次資料に基づく文献レビュー(15 文書、約 3,800 行):research/
本番環境への統合
コード内の LLM 応答を傍受するための 3 つの方法です。すべてローカルで実行されます(応答がマシンの外部に送信されることはありません)。
A)EIFInterceptor - 既存の OpenAI クライアントをラップする
from openai import OpenAI
from eif.sdk import EIFInterceptor, EIFHaltError
client = OpenAI()
eif = EIFInterceptor(api_key="eif-...", client=client)
try:
response = eif.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Evaluate this plan: ..."}],
)
print(response.choices[0].message.content)
except EIFHaltError as e:
print("HALT:", e.halt_record)
# Do not act on this response - EIF found a claim without independent evidence.
インストール:pip install "eif-engine[sdk]"(またはソースチェックアウトから pip install -e ".[sdk]")
注:EIF サーバーでエラーが発生した場合、SDK はフェイルオープンで動作し、応答は未検証のまま通過します。そのため、EIF が利用できなくてもエージェントがブロックされることはありません。強制適用シグナルとして扱うのは EIFHaltError のみです。
B)eif.auto - 設定不要のインポートフック
import eif.auto # add once at your agent's entry point
# All subsequent OpenAI and Anthropic calls are intercepted automatically.
# EIFHaltError is raised if a HALT verdict is reached.
環境変数で設定します。
export EIF_API_KEY="eif-..."
export EIF_SERVER_URL="http://localhost:8080" # default
export EIF_HALT_MODE="raise" # raise | log | callback
HTTP サーバーを起動します:eif-mcp-http-server
C)EIFCallbackHandler - LangChain/LangGraph
from langchain.agents import AgentExecutor
from eif.sdk import EIFCallbackHandler, EIFHaltError
handler = EIFCallbackHandler(api_key="eif-...")
agent = AgentExecutor(agent=agent, tools=tools, callbacks=[handler])
try:
result = agent.invoke({"input": task})
except EIFHaltError as e:
print("HALT:", e.halt_record)
HTTP サーバーを必要としない、プロセス内での LangChain 統合には、従来の統合レイヤーを使用してください。
from eif.integration import EIFInterceptor, EIFHaltError
interceptor = EIFInterceptor(session_id="my-session")
chain = my_chain.with_config(callbacks=[interceptor])
設計原則
- エンジン内では LLM を呼び出さない - すべての計算は決定論的なローカル計算です。LLM の呼び出しは証拠収集(P3/P4)と主張の抽出(統合レイヤー)でのみ行われます
- 全体を通じて Pydantic v2 を使用 - すべての入力と出力は、型付けされ、検証済みのモデルです
- H₀ = 主張はTRUE - Popper の考え方では、REJECT は主張が成立しないことを意味します
- EIG による停止ルール - KL(posterior ∥ prior) < 0.01 nats になったら、証拠の収集を停止します
- IMP4 方向の法則 -
CONTRADICTSの証拠には、SUPPORTSと同じ尤度ではなく、低いP(E|H)を使用する必要があります - P4 の目標は 0% - 企業固有または因果に関する主張に対して、パラメトリックな自己検証を使用することはありません
検証コーパス
コーパス全体:validation/
| ファイル | 説明 |
|---|---|
CORPUS_REPORT.md | 14 のシナリオ、84 回のエージェントのターンにわたる結果の集計 |
EIF_INVESTMENT_V31_EVIDENCE.md | サンプル:投資判断 - シリーズ A、6 ターン |
シナリオごとの追加エビデンスレポート(S6v31–S20)は、GitHub Discussions からリクエストできます。
開発
git clone https://github.com/leocelis/eif && cd eif
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,mcp]"
pytest -q
リポジトリの構成、コードスタイル、PR チェックリストについては、CONTRIBUTING.md をご覧ください。
CI では、テストスイート(Python 3.11 および 3.12)に加え、インテントアーティファクトを対象とした TrustLint による EU AI Act 審査(./scripts/compliance/check.sh)が実行されます。詳細なセットアップと現在のトラストサーフェスについては、docs/integrations/COMPLYEDGE.md をご覧ください。
コミュニティ
- バグ:GitHub Issues
- 質問やアイデア:GitHub Discussions
- セキュリティに関する報告:SECURITY.md をご覧ください
法務
| ドキュメント | 対象 |
|---|---|
| LICENSE | コードに適用される MIT ライセンス |
| LEGAL.md | EIF の内容と対象外事項、性能に関する主張の範囲、制限、導入者の義務 |
| TERMS_OF_SERVICE.md | リポジトリ、ドキュメント、プロジェクトサイトの利用 |
| PRIVACY_POLICY.md | テレメトリーなし、セルフホスト時はカテゴリ単位でデータを収集しないこと、任意のホスト型アルファ版がクレームのテキストをどのように扱うか |
| DATA_PROCESSING_AGREEMENT.md | 社内エンタープライズ導入向けのテンプレート(未発効) |
| SECURITY.md | 脆弱性の報告 |
| NOTICE | サードパーティのクレジット |
この README に記載されている性能および市場の数値は、モデルによる推定値またはサードパーティによる推定値であり、本番環境で測定された結果ではありません。LEGAL.md をご覧ください。
ライセンス
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。