Skip to content

API Reference parrot.knowledge.wiki.execution

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

parrot.knowledge.wiki.execution

View source

ExecutionWikiRecorder — crew/flow execution content in the LLM Wiki plane.

Records everything an :class:~parrot.bots.flows.crew.crew.AgentCrew run produces — the run itself, every intermediate per-agent result, and every intermediate tool-call result — as wiki pages + typed edges in a per-crew :class:~parrot.knowledge.wiki.store.SQLiteWikiStore (wiki.db), so the existing wiki search machinery (FTS5/BM25 + optional embedding cosine) can search inside the research, not just over final outputs.

Page/edge mapping (categories and relations are open strings — the machine plane has no enum ceremony):

===================== =================================== ============== Content concept_id category ===================== =================================== ============== Crew run run:{execution_id} crew_run Agent/tool-node result agent:{execution_id}:{node_id} agent_result Tool call tool:{execution_id}:{node_id}:N tool_result ===================== =================================== ==============

Edges: run —contains→ agent, agent —follows→ previous agent, agent —used_tool→ tool. Every page carries source_id = "exec:{execution_id}" so a single run can be filtered.

The store is the standard wiki.db schema, so the wikitoolkit CLI reads it directly (wikitoolkit query "<q>" --store <storage_dir> or --path <storage_dir> — the recorder writes a minimal .parrot/wiki.json next to the database for the latter).

All public record methods are failure-tolerant: they log and continue, never raising into the crew's execution path (mirrors PersistenceMixin._save_result error handling).

Alias BaseWikiStore

Re-exported from parrot.knowledge.wiki.store.BaseWikiStore.

Attribute CATEGORY_AGENT

Attribute CATEGORY_RUN

Attribute CATEGORY_TOOL

Attribute DEFAULT_BODY_MAX_CHARS

Attribute DEFAULT_WIKI_ROOT

Class ExecutionWikiRecorder

Persist crew execution content into a WikiStore SQLite plane.

One recorder per crew: pages from every run accumulate in the same wiki.db (tagged by execution_id), enabling cross-run research search.

Parameter Type Default Description
storage_dir str | Path Directory holding wiki.db (created on demand).
crew_name str Crew name recorded in the wiki meta table.
embedding_model Any None Optional embedding source for the vector search leg. Accepts an async text -> list[float] callable, a SentenceTransformer-like object (sync .encode), or a parrot EmbeddingModel wrapper. BM25-only when None or unusable.
body_max_chars int DEFAULT_BODY_MAX_CHARS Cap applied to stored page bodies.
write_project_config bool True When True (default), write a minimal .parrot/wiki.json inside storage_dir so wikitoolkit ... --path <storage_dir> resolves the plane.
publisher Any None

Attributes:

Attribute Type Description
store BaseWikiStore The underlying wiki retrieval-plane store.

Method ExecutionWikiRecorder.run_page_id

concept_id of a run page.

run_page_id(execution_id: str) -> str

Parameter Type Default Description
execution_id str

Returns: str

Method ExecutionWikiRecorder.agent_page_id

concept_id of an agent-result page.

agent_page_id(execution_id: str, node_id: str) -> str

Parameter Type Default Description
execution_id str
node_id str

Returns: str

Method ExecutionWikiRecorder.tool_page_id

concept_id of a tool-call page.

tool_page_id(execution_id: str, node_id: str, call_id: str) -> str

Parameter Type Default Description
execution_id str
node_id str
call_id str

Returns: str

Method ExecutionWikiRecorder.record_run_start

Record the start of a crew run as a crew_run page.

record_run_start(execution_id: str, method: str, task: Any, user_id: Optional[str] = None, session_id: Optional[str] = None, tenant: Optional[str] = None) -> None

Parameter Type Default Description
execution_id str Crew-level execution id.
method str Execution method name (e.g. "run_sequential").
task Any The initial task/prompt (any type; rendered as text).
user_id Optional[str] None Optional user identifier.
session_id Optional[str] None Optional session identifier.
tenant Optional[str] None Optional tenant identifier.

Method ExecutionWikiRecorder.record_agent_result

Record one agent's intermediate result and its tool calls.

Writes the agent_result page, one tool_result page per tool call, and the contains/follows/used_tool edges.

record_agent_result(execution_id: str, node_result: Any, tool_calls: Optional[List[Any]] = None) -> None

Parameter Type Default Description
execution_id str Crew-level execution id linking pages to the run.
node_result Any The per-agent execution record (NodeResult — anything exposing node_id/agent_id, node_name, task, and to_text()).
tool_calls Optional[List[Any]] None Serialised tool-call records (dicts or ToolCall objects with id/name/arguments/result/ error/execution_time).

Method ExecutionWikiRecorder.record_run_end

Record the completion of a crew run on its crew_run page.

record_run_end(execution_id: str, result: Any, method: Optional[str] = None) -> None

Parameter Type Default Description
execution_id str Crew-level execution id.
result Any The final result — a FlowResult (output, summary, status, total_time) or any object rendered as text.
method Optional[str] None Optional execution method name (kept from run start when omitted).

Method ExecutionWikiRecorder.search

Search the execution wiki (BM25 + optional embedding cosine).

search(query: str, top_k: int = 10, category: Optional[str] = None, execution_id: Optional[str] = None, lexical_weight: float = 0.6, vector_weight: float = 0.4) -> List[Dict[str, Any]]

Parameter Type Default Description
query str Natural-language query.
top_k int 10 Maximum merged results.
category Optional[str] None Optional exact category filter (crew_run / agent_result / tool_result).
execution_id Optional[str] None Optional filter to a single run.
lexical_weight float 0.6 Weight of the BM25 leg when both legs return.
vector_weight float 0.4 Weight of the cosine leg when both legs return.

Returns: List[Dict[str, Any]] — Result dicts (concept_id, title, category, summary, source_id, token_count, score in [0, 1], source = "lexical"/"vector"), best first.

Method ExecutionWikiRecorder.get_page

Read one execution-wiki page (progressive disclosure).

get_page(concept_id: str, include_body: bool = True) -> Optional[Dict[str, Any]]

Parameter Type Default Description
concept_id str Page identity (run:.../agent:.../tool:...).
include_body bool True When False the body column is omitted.

Returns: Optional[Dict[str, Any]] — Page dict or None when not found / on error.

Method ExecutionWikiRecorder.related

Follow typed edges from a page (contains/follows/used_tool).

related(concept_id: str, rel: Optional[str] = None, direction: str = 'both') -> List[Dict[str, Any]]

Parameter Type Default Description
concept_id str Seed page identity.
rel Optional[str] None Optional exact relation filter.
direction str 'both' "out", "in", or "both".

Returns: List[Dict[str, Any]] — Neighbour dicts (empty on error).

Method ExecutionWikiRecorder.stats

Plane statistics (page/edge counts etc.); empty dict on error.

stats() -> Dict[str, Any]

Returns: Dict[str, Any]

Method ExecutionWikiRecorder.aclose

Release the underlying store (no-op for the SQLite backend).

aclose() -> None

Attribute REL_CONTAINS

Attribute REL_FOLLOWS

Attribute REL_USED_TOOL

Alias WikiPageRecord

Re-exported from parrot.knowledge.wiki.store.WikiPageRecord.

Alias WikiProjectConfig

Re-exported from parrot.knowledge.wiki.project.WikiProjectConfig.

Alias create_wiki_store

Re-exported from parrot.knowledge.wiki.store.create_wiki_store.

Function crew_slug

Return a filesystem-safe slug for a crew name.

crew_slug(name: str) -> str

Parameter Type Default Description
name str Human-readable crew name.

Returns: str — Lower-cased slug with non-alphanumeric runs collapsed to -.

Function default_wiki_dir

Resolve the default storage directory for a crew's execution wiki.

default_wiki_dir(crew_name: str, base_dir: Optional[Path] = None) -> Path

Parameter Type Default Description
crew_name str Crew name (slugified for the directory).
base_dir Optional[Path] None Base directory; defaults to the current working directory.

Returns: Path — {base_dir}/.parrot/crew_wiki/{crew-slug}.

Alias estimate_tokens

Re-exported from parrot.knowledge.wiki.store.estimate_tokens.

Attribute logger

Alias save_project_config

Re-exported from parrot.knowledge.wiki.project.save_project_config.

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