[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-82912":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":14,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":16,"rankGlobal":9,"rankLanguage":9,"license":17,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":9,"pushedAt":9,"updatedAt":22,"readmeContent":23,"aiSummary":24,"trendingCount":15,"starSnapshotCount":15,"syncStatus":25,"lastSyncTime":26,"discoverSource":27},82912,"AgentClaimGuard","konoeph\u002FAgentClaimGuard","konoeph","Evidence gate for LLM agent claims - verify claims against evidence, tool results, and policies.",null,"Python",52,5,4,1,0,2.33,"Apache License 2.0",false,"main",true,[],"2026-06-12 02:04:29","# AgentClaimGuard\n\n[![CI](https:\u002F\u002Fgithub.com\u002Fkonoeph\u002FAgentClaimGuard\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fkonoeph\u002FAgentClaimGuard\u002Factions\u002Fworkflows\u002Fci.yml)\n[![Release](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fv\u002Frelease\u002Fkonoeph\u002FAgentClaimGuard)](https:\u002F\u002Fgithub.com\u002Fkonoeph\u002FAgentClaimGuard\u002Freleases\u002Flatest)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flicense\u002Fkonoeph\u002FAgentClaimGuard)](.\u002FLICENSE)\n\nInstall from PyPI:\n\n```bash\npip install agentclaimguard\n```\n\nAgentClaimGuard is a framework-agnostic evidence gate for LLM agent claims.\n\nIt verifies whether important claims in LLM outputs are supported by evidence,\ntool results, and user-defined policies.\n\nAgentClaimGuard does not decide whether a claim is true by itself. It verifies\nwhether a claim is allowed to be returned under a user-defined evidence and tool\npolicy.\n\nAgentClaimGuard is released under Apache-2.0 to support open-source, research,\nand commercial integration across LLM agent applications.\n\nNo evidence, no claim.  \nNo tool result, no numeric conclusion.  \nNo source, no compliance judgment.\n\n## Why AgentClaimGuard?\n\nLLM applications can produce fluent, structured, and confident answers even when\nthe key claims are unsupported.\n\nRAG gives context, but does not guarantee the answer is grounded. Tool calling\ngives results, but does not guarantee the model uses them. Structured output\ngives JSON, but does not guarantee the judgment is valid.\n\nAgentClaimGuard adds a lightweight runtime layer to verify claims before they are\nreturned to users.\n\n## Tiny Example\n\nAn agent says:\n\n```text\nRevenue increased by 15%.\n```\n\nThe workflow provides source facts, but no calculator result.\n\nAgentClaimGuard returns:\n\n```text\nstatus=blocked\nclaim_status=tool_required\nsafe_verdict=insufficient_evidence\n```\n\nThe answer can be routed to repair, retrieval, or human review instead of being\nreturned directly.\n\n## Install\n\nInstall from PyPI:\n\n```bash\npip install agentclaimguard\n```\n\nWith optional adapters and server dependencies:\n\n```bash\npip install \"agentclaimguard[server]\"\npip install \"agentclaimguard[langgraph]\"\npip install \"agentclaimguard[langchain]\"\n```\n\nFor local development:\n\n```bash\npip install -e \".[dev,server,langgraph,langchain]\"\n```\n\n## Quickstart\n\n```bash\npip install agentclaimguard\n```\n\n```python\nfrom agentclaimguard import AgentClaimGuard, Policy\n\nguard = AgentClaimGuard(Policy.load_builtin(\"generic_strict\"))\nresult = guard.verify(claims=[], evidence=[], tool_results=[])\n\nprint(result.status)\n```\n\nTo run the FastAPI server:\n\n```bash\npip install \"agentclaimguard[server]\"\nuvicorn agentclaimguard.server.main:app --reload\n```\n\nTo run the repository demos from a local clone:\n\n```bash\npip install -e \".[dev,server,langgraph,langchain]\"\npython examples\u002Fnumeric_conclusion\u002Fdemo.py\n```\n\n## LangGraph Adapter\n\nAgentClaimGuard can run as a LangGraph node between an agent step and routing\nlogic. Use a typed state schema so LangGraph keeps `guard_result` in the graph\nstate:\n\n```python\nfrom typing import Any, TypedDict\n\nfrom langgraph.graph import END, START, StateGraph\nfrom agentclaimguard import Policy\nfrom agentclaimguard.adapters.langgraph import (\n    create_evidence_guard_node,\n    route_by_guard_status,\n)\n\n\nclass GuardState(TypedDict, total=False):\n    claims: list[dict[str, Any]]\n    evidence: list[dict[str, Any]]\n    tool_results: list[dict[str, Any]]\n    guard_result: object\n\n\npolicy = Policy.load_builtin(\"generic_numeric\")\nguard_node = create_evidence_guard_node(policy=policy)\n\nbuilder = StateGraph(GuardState)\nbuilder.add_node(\"agent\", agent_node)\nbuilder.add_node(\"guard\", guard_node)\nbuilder.add_node(\"repair\", repair_node)\nbuilder.add_node(\"human_review\", human_review_node)\nbuilder.add_edge(START, \"agent\")\nbuilder.add_edge(\"agent\", \"guard\")\nbuilder.add_conditional_edges(\n    \"guard\",\n    route_by_guard_status,\n    {\n        \"passed\": END,\n        \"blocked\": \"repair\",\n        \"need_check\": \"human_review\",\n        \"insufficient_evidence\": \"human_review\",\n        \"conflicting_evidence\": \"human_review\",\n    },\n)\nbuilder.add_edge(\"repair\", END)\nbuilder.add_edge(\"human_review\", END)\n```\n\nIf your graph uses a different state field, pass the same `result_key` to both\n`create_evidence_guard_node(...)` and `route_by_guard_status(...)`.\n\nRun the minimal adapter demo. If `langgraph` is not installed, the demo falls\nback to direct node invocation and prints the same guard decision:\n\n```bash\npip install -e \".[langgraph]\"\npython examples\u002Flanggraph_guard\u002Fdemo.py\n```\n\nSee [examples\u002Flanggraph_guard\u002FREADME.md](examples\u002Flanggraph_guard\u002FREADME.md) for\nthe full walkthrough.\n\n## LangChain Adapter\n\nAgentClaimGuard can also wrap a LangChain Runnable and attach verification to\nits output:\n\n```python\nfrom langchain_core.runnables import RunnableLambda\n\nfrom agentclaimguard import Policy\nfrom agentclaimguard.adapters.langchain import create_guarded_runnable\n\nchain = RunnableLambda(lambda payload: {\n    \"final_answer\": payload[\"question\"],\n    \"claims\": payload[\"claims\"],\n    \"evidence\": payload[\"evidence\"],\n    \"tool_results\": payload[\"tool_results\"],\n})\n\nguarded = create_guarded_runnable(\n    runnable=chain,\n    policy=Policy.load_builtin(\"generic_numeric\"),\n)\n\nresult = guarded.invoke(input_data)\nprint(result[\"guard_result\"].status)\n```\n\nUse `field_map` when the Runnable output uses custom keys for claims, evidence,\nor tool results. String-based field maps resolve Runnable output first and then\nfall back to Runnable input; callable extractors receive both input and output.\n`ainvoke(...)` is also supported for async chains.\n\nBy default, the wrapper raises `ValueError` if the Runnable output already\ncontains the chosen `result_key`. Use a different `result_key`, or set\n`overwrite_result=True` when replacement is intentional.\n\nRun the minimal adapter demo:\n\n```bash\npython examples\u002Flangchain_guard\u002Fdemo.py\n```\n\n## Dify HTTP Tool\n\nAgentClaimGuard can be called from a Dify workflow as a plain HTTP tool using\nthe FastAPI server:\n\n```text\nDify workflow -> HTTP tool -> POST \u002Fv1\u002Fverify -> guard decision\n```\n\nRun the server and use the example payload:\n\n```bash\npip install \"agentclaimguard[server]\"\nuvicorn agentclaimguard.server.main:app --host 0.0.0.0 --port 8000\ncurl -X POST http:\u002F\u002Flocalhost:8000\u002Fv1\u002Fverify \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  --data @examples\u002Fdify_http_tool\u002Frequest.json\n```\n\nSee [examples\u002Fdify_http_tool\u002FREADME.md](examples\u002Fdify_http_tool\u002FREADME.md) for\nthe Dify HTTP tool setup notes.\n\n## Claim Extraction Helper\n\nAgentClaimGuard also includes optional deterministic helpers for turning\nclaim-like items into structured `Claim` objects:\n\n```python\nfrom agentclaimguard.extractors import (\n    ClaimExtractionTemplate,\n    create_claims_from_items,\n)\n\ntemplate = ClaimExtractionTemplate.default()\nprompt = template.format(\n    answer=\"Revenue increased by 15%.\",\n    claim_types=[\"numeric_conclusion\"],\n)\n\nextraction = create_claims_from_items([\n    {\n        \"text\": \"Revenue increased by 15%.\",\n        \"claim_type\": \"numeric_conclusion\",\n        \"evidence_refs\": [\"ev_1\", \"ev_2\"],\n    }\n])\n```\n\nThe helper does not call an LLM and does not verify truth.\n\n```text\nExtraction != Verification\n```\n\nSee [examples\u002Fclaim_extraction\u002FREADME.md](examples\u002Fclaim_extraction\u002FREADME.md)\nfor a minimal extraction-to-verification demo.\n\n## RAGFlow Evidence Provider\n\nRAGFlow-style retrieved chunks can be mapped into AgentClaimGuard `Evidence`\nrecords before verification:\n\n```text\nRAGFlow \u002F RAG system retrieves chunks\n        -> map chunks to Evidence\n        -> AgentClaimGuard.verify(...)\n```\n\nThis is a mapping pattern, not a RAGFlow plugin or retrieval engine.\n\nSee [examples\u002Fragflow_evidence\u002FREADME.md](examples\u002Fragflow_evidence\u002FREADME.md)\nfor a copyable chunk-to-evidence example.\n\n## Integration Patterns\n\nAgentClaimGuard can be embedded in three common ways:\n\n```text\nHTTP tool          Dify \u002F workflow platform -> POST \u002Fv1\u002Fverify\nEvidence provider RAGFlow \u002F RAG system -> Evidence[]\nFramework adapter LangGraph node \u002F LangChain Runnable -> guard_result\n```\n\nSee [docs\u002Fadapters.md](docs\u002Fadapters.md) for when to use each pattern.\n\n## Example Outputs\n\nSee [docs\u002Fexamples.md](docs\u002Fexamples.md) for full sample output. Short version:\n\n```text\nnumeric_conclusion  -> blocked \u002F tool_required \u002F insufficient_evidence\ncompliance_judgement -> blocked \u002F insufficient_evidence \u002F need_check\nrag_citation        -> blocked \u002F insufficient_evidence\n```\n\n## Core Flow\n\n```text\nClaim -> Evidence -> Tool -> Verify\n```\n\n## Issues & Roadmap\n\n- Open issues: [GitHub Issues](https:\u002F\u002Fgithub.com\u002Fkonoeph\u002FAgentClaimGuard\u002Fissues)\n- Roadmap: [docs\u002Froadmap.md](docs\u002Froadmap.md)\n- Adapter plan: [docs\u002Fadapters.md](docs\u002Fadapters.md)\n- LangChain demo: [examples\u002Flangchain_guard\u002Fdemo.py](examples\u002Flangchain_guard\u002Fdemo.py)\n- Claim extraction demo: [examples\u002Fclaim_extraction\u002Fdemo.py](examples\u002Fclaim_extraction\u002Fdemo.py)\n- Dify HTTP tool example: [examples\u002Fdify_http_tool\u002FREADME.md](examples\u002Fdify_http_tool\u002FREADME.md)\n- RAGFlow evidence example: [examples\u002Fragflow_evidence\u002FREADME.md](examples\u002Fragflow_evidence\u002FREADME.md)\n- Troubleshooting: [docs\u002Ftroubleshooting.md](docs\u002Ftroubleshooting.md)\n- Release checklist: [docs\u002Frelease_checklist.md](docs\u002Frelease_checklist.md)\n\n## What AgentClaimGuard Is Not\n\nAgentClaimGuard is not an agent framework, RAG engine, vector database, or\ngeneral-purpose safety guardrail.\n\nIt is a claim-level reliability layer for LLM applications.\n\n## License\n\nCopyright 2026 Hao Peng (彭浩).\n\nAgentClaimGuard is available under the [Apache-2.0 License](LICENSE).\n","AgentClaimGuard 是一个用于验证大型语言模型（LLM）输出中重要声明是否基于证据、工具结果及用户定义策略的框架无关证据门。其核心功能包括检查声明是否有足够的支持依据，确保只有符合预设规则的信息才会被返回给用户。该项目采用 Python 编写，支持通过 PyPI 安装，并提供多种适配器以适应不同应用场景。特别适合需要增强 LLM 应用程序可靠性和合规性的场景，如企业级聊天机器人、智能客服系统等，在这些环境中，确保信息准确性和来源可信度至关重要。",2,"2026-06-11 04:09:38","CREATED_QUERY"]