Skip to content

API Reference parrot.sdd.scripts.experience_hook

github-actions[bot] edited this page Dec 2, 2026 · 1 revision

parrot.sdd.scripts.experience_hook

View source

Bounded stdlib hook adapter; executable as an isolated module.

Attribute ISOLATED_ENV

Alias agy_exit_code

Re-exported from parrot.knowledge.wiki.experience.fastpath.agy_exit_code.

Function agy_outcome

Read a GENERIC step result and header-only exit status.

agy_outcome(transcript_path: Path, step_idx: int, *, max_bytes: int) -> tuple[bool, str] | None

Parameter Type Default Description
transcript_path Path Agy transcript JSONL path.
step_idx int Host step index to resolve.
max_bytes int Maximum transcript tail to inspect.

Returns: tuple[bool, str] | None — The command result, or None for missing, unsafe, or unknown records.

Alias best_trigger

Re-exported from parrot.knowledge.wiki.experience.fastpath.best_trigger.

Function codex_outcome

Join a bounded rollout tail by CommandExecution item.id.

codex_outcome(transcript_path: Path, tool_use_id: str, *, max_bytes: int) -> tuple[bool, str] | None

Parameter Type Default Description
transcript_path Path Codex rollout JSONL path.
tool_use_id str Command execution item id from the callback.
max_bytes int Maximum rollout tail to inspect.

Returns: tuple[bool, str] | None — The command result, or None for missing, unsafe, or unknown records.

Function command_of

Extract Bash or run_command input; otherwise return empty string.

command_of(payload: Mapping[str, Any], host: str) -> str

Parameter Type Default Description
payload Mapping[str, Any] Host callback payload.
host str Calling host name.

Returns: str — The host-reported command, or an empty string for non-command tools.

Alias frozen_plane_dir

Re-exported from parrot.knowledge.wiki.experience.fastpath.frozen_plane_dir.

Function handle_post

Handle known outcomes, or queue an agy pending transcript lookup.

handle_post(payload: Mapping[str, Any], *, host: str, event: str, plane_dir: Path) -> str | None

Parameter Type Default Description
payload Mapping[str, Any] Host callback payload.
host str Calling host name.
event str Normalized hook event.
plane_dir Path Shared experience plane.

Returns: str | None — Advisory text emitted by the transition engine, if any.

Function handle_post_invocation

Resolve agy pending commands; unknown results defer to replay.

handle_post_invocation(payload: Mapping[str, Any], *, plane_dir: Path) -> str | None

Parameter Type Default Description
payload Mapping[str, Any] Agy PostInvocation callback payload.
plane_dir Path Shared experience plane.

Returns: str | None — The first produced advisory text, if any.

Alias load_hook_limits

Re-exported from parrot.knowledge.wiki.experience.fastpath.load_hook_limits.

Alias load_triggers

Re-exported from parrot.knowledge.wiki.experience.fastpath.load_triggers.

Function main

Read bounded stdin and emit advisory host JSON; all paths return zero.

main(argv: Sequence[str] | None = None) -> int

Parameter Type Default Description
argv Sequence[str] | None None Hook command-line arguments, excluding the executable name.

Returns: int — Always zero so an advisory hook never blocks its host.

Function observation_of

Return tool_use_id or conversationId:stepIdx.

observation_of(payload: Mapping[str, Any], host: str) -> str

Parameter Type Default Description
payload Mapping[str, Any] Host callback payload.
host str Calling host name.

Returns: str — Stable host observation identity, or an empty string when unavailable.

Alias on_outcome

Re-exported from parrot.knowledge.wiki.experience.transitions.on_outcome.

Function outcome_of

Return a known command outcome, otherwise None.

outcome_of(payload: Mapping[str, Any], host: str, event: str, *, max_transcript_tail_bytes: int = _MAX_TRANSCRIPT_TAIL_BYTES) -> tuple[bool, str] | None

Parameter Type Default Description
payload Mapping[str, Any] Host callback payload.
host str Calling host name.
event str Normalized event name.
max_transcript_tail_bytes int _MAX_TRANSCRIPT_TAIL_BYTES

Returns: tuple[bool, str] | None — A success/error pair only when the host provided a trustworthy result.

Function render

Return the exact M4 host response envelope.

render(advice: str, *, host: str, event: str) -> dict[str, Any]

Parameter Type Default Description
advice str Advisory text to pass to the host.
host str Calling host name.
event str Normalized hook event.

Returns: dict[str, Any] — The host-specific advisory envelope.

Alias resolve_plane_dir

Re-exported from parrot.knowledge.wiki.experience.fastpath.resolve_plane_dir.

Alias safe_open

Re-exported from parrot.knowledge.wiki.experience.fastpath.safe_open.

Alias session_file

Re-exported from parrot.knowledge.wiki.experience.fastpath.session_file.

Function session_of

Return env/host session key suffixed by nonempty agent_id.

session_of(payload: Mapping[str, Any], env: Mapping[str, str]) -> str

Parameter Type Default Description
payload Mapping[str, Any] Host callback payload.
env Mapping[str, str] Environment variables visible to the hook.

Returns: str — Opaque session identity, never used as a filesystem path.

Alias update_session

Re-exported from parrot.knowledge.wiki.experience.fastpath.update_session.

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