Skip to content

API Reference parrot.stores.kb.hierarchy

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.stores.kb.hierarchy

View source

Alias AbstractKnowledgeBase

Re-exported from parrot.stores.kb.abstract.AbstractKnowledgeBase.

Class EmployeeHierarchyKB

Knowledge Base what provides employee hierarchy context.

Extracts the associate_oid of the user from the session and searches for:

  • Their direct boss and chain of command
  • Their department and unit
  • Their colleagues
  • Their direct reports (if they are a manager)

This context is automatically incorporated into the user-context so that the LLM is aware of the user's hierarchical position. Args: permission_service: An instance of HierarchyPermissionService to fetch hierarchy data. always_active: If True, this KB is always active (default True) priority: The priority of this KB (higher = included first)

Example:

hierarchy_kb = EmployeeHierarchyKB(
    permission_service=service,
    always_active=True
)
bot.register_kb(hierarchy_kb)
Parameter Type Default Description
permission_service EmployeeHierarchyManager
always_active bool True
priority int 10
employee_id_field str 'employee_id'
**kwargs {}

Method EmployeeHierarchyKB.close

Cleanup resources if needed.

close()

Method EmployeeHierarchyKB.should_activate

should_activate(query: str, context: Dict[str, Any]) -> Tuple[bool, float]

Parameter Type Default Description
query str
context Dict[str, Any]

Returns: Tuple[bool, float]

Method EmployeeHierarchyKB.search

Search and return the employee hierarchy context.

search(query: str, user_id: str = None, session_id: str = None, ctx: RequestContext = None, **kwargs) -> List[Dict[str, Any]]

Parameter Type Default Description
query str User query (not used directly)
user_id str None User ID
session_id str None Session ID
ctx RequestContext None RequestContext with session information
**kwargs {}

Returns: List[Dict[str, Any]] — List of facts about the employee hierarchy

Method EmployeeHierarchyKB.format_context

Final string injected into the Agent System Prompt.

Puts the compact JSON-like context first so tools/LLM can parse it, then short readable bullets.

format_context(results: List[Dict[str, Any]]) -> str

Parameter Type Default Description
results List[Dict[str, Any]]

Returns: str

Alias EmployeeHierarchyManager

Re-exported from parrot.interfaces.hierarchy.EmployeeHierarchyManager.

Alias RequestContext

Re-exported from parrot.utils.helpers.RequestContext.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally