Files
semantica/tests/context/test_agent_context_smoke.py
T
KaifAhmad1 14f5e05336 Update context documentation with user-friendly approach and strategic emoji placement
- Enhanced README.md with strategic emojis for better visual appeal
- Updated context_usage.md with detailed, user-friendly examples
- Improved docs/reference/context.md with accessible language
- Added AgentContext sections with progressive learning approach
- Maintained professional appearance while improving readability
- Consistent documentation across all context module files
2026-02-16 17:40:50 +05:30

67 lines
1.9 KiB
Python

import pytest
from semantica.context import AgentContext, ContextGraph
from semantica.context.decision_models import Policy
from semantica.vector_store import VectorStore
from datetime import datetime
def test_agent_context_minimal_decisions_and_chain():
vs = VectorStore(backend="inmemory", dimension=64)
graph = ContextGraph()
ctx = AgentContext(
vector_store=vs,
knowledge_graph=graph,
decision_tracking=True,
kg_algorithms=False,
vector_store_features=False,
)
d1 = ctx.record_decision(
category="credit_approval",
scenario="s1",
reasoning="r1",
outcome="rejected",
confidence=0.8,
entities=["e1"],
decision_maker="tester",
)
d2 = ctx.record_decision(
category="credit_approval",
scenario="s2",
reasoning="r2",
outcome="rejected",
confidence=0.85,
entities=["e1"],
decision_maker="tester",
)
graph.add_causal_relationship(d1, d2, "INFLUENCED")
chain = ctx.get_causal_chain(d2, direction="upstream", max_depth=5)
assert isinstance(chain, list)
assert len(chain) >= 1
def test_agent_context_policy_engine_with_graph_backend():
vs = VectorStore(backend="inmemory", dimension=64)
graph = ContextGraph()
ctx = AgentContext(
vector_store=vs,
knowledge_graph=graph,
decision_tracking=True,
kg_algorithms=False,
vector_store_features=False,
)
pe = ctx.get_policy_engine()
pol = Policy(
policy_id="cp",
name="Credit Policy",
description="d",
rules={"min_confidence": 0.8, "allowed_outcomes": ["approved", "rejected"]},
category="credit_approval",
version="1.0.0",
created_at=datetime.now(),
updated_at=datetime.now(),
metadata={},
)
pe.add_policy(pol)
found = pe.get_policy("cp")
assert found is not None