Skip to content

Graphorin API reference v0.1.0


Graphorin API reference / @graphorin/agent / filters

filters

Handoff filter library — a small set of pure, composable functions that take the parent agent's message history and return a filtered subset suitable for forwarding to a child agent.

Every filter pairs a HandoffFilter runtime function with a serializable HandoffInputFilterDescriptor so the JSONL session export (@graphorin/sessions) can replay the filter stack even after the runtime implementations evolve.

Reasoning content is always stripped at the handoff boundary — filters.compose(...) guarantees stripReasoning() runs last so a caller-supplied filter cannot accidentally forward reasoning to a child agent. This is the confidentiality + token-economy default documented in the agent-loop reference.

Interfaces

InterfaceDescription
DescribedFilterA HandoffFilter paired with the serializable descriptor that round-trips through the JSONL session export. Authors of custom filters return one of these via filters.custom({...}).

Variables

VariableDescription
FILTER_KIND_CUSTOMPure HandoffInputFilterDescriptor for callers that just need the descriptor without instantiating the runtime function (e.g. the sessions package's lenient-forward-parse path).
filtersAggregate module export.

Functions

FunctionDescription
bySensitivityDrop messages whose effective sensitivity ceiling exceeds maxTier. Messages without sensitivity metadata default to 'public' and are always kept.
composeCompose multiple filters left-to-right. The composer always appends stripReasoning() at the end so reasoning content never crosses a handoff boundary regardless of caller intent.
customWrap a caller-supplied function as a DescribedFilter with the canonical 'custom' descriptor.
defaultHandoffFilterThe canonical default applied by the agent runtime to every Agent.toTool(...) and handoff(...) invocation when the caller does not supply an explicit filter.
fullThe full unfiltered history. Emits a deprecation warning per call — security-conscious callers should pick lastN or bySensitivity instead.
lastNKeep the parent's system prompt and the last n non-system messages. Default n = 10 per DEC-146 / RB-40 security-first compose.
lastUserKeep only the parent's system prompt and the most recent user message. Useful for simple sub-agents that only need the question.
stripReasoningStrip every ReasoningContent part from each message. Always applied at the handoff boundary (the compose(...) helper appends this filter automatically).
stripSensitiveOutputsStrip tool messages whose content carries the literal token [REDACTED:secret] or whose secret annotation marks the body as sensitive. Conservative-by-design: the agent runtime tags sensitive tool outputs at session-write time so this filter has stable bytes to scan against.
stripToolCallsDrop every assistant toolCalls array AND every tool message. Useful when a sub-agent should only see the textual conversation.
summaryReplace the parent's history with a single system message carrying the supplied summary. Used by callers that wire in an LLM-based summarizer outside the framework.