OversizedResultGuard class

Intercepts tool results exceeding threshold bytes and replaces them with an ArtifactReference before they enter model context (FR-010).

If artifactStorage is unavailable (returns false), the result is truncated with a marker (degraded but not broken — per spec edge case).

Inheritance

Constructors

OversizedResultGuard({required int threshold, required Future<String?> artifactStorage(Object? payload), String truncationMarker = '<truncated>'})

Properties

artifactStorage → Future<String?> Function(Object? payload)
Callback that stores payload externally and returns the artifact URI (or null if storage is unavailable — triggers truncation).
final
enabled ↔ bool
Whether this hook is currently active. Disabled hooks are skipped by the PolicyShell.
getter/setter pairinherited
hashCode → int
The hash code for this object.
no setterinherited
id → String
Stable identifier for this hook (e.g. tool_gating, mission_budget, mission_trace).
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
threshold → int
Maximum payload size before the guard swaps in an ArtifactReference.
final
truncationMarker → String
final

Methods

afterToolCall(ToolCallContext ctx, ToolResult result) → Future<ToolResult>
Called after a tool has returned. May modify result (e.g., the oversized-result guard swaps in an ArtifactReference).
override
beforeToolCall(ToolCallContext ctx) → Future<HookDecision>
Called before a tool is invoked. Returns a HookDecision that the shell uses to allow / deny / cancel the call.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onMissionEnd(String missionId) → Future<void>
Called once when the mission ends (terminal state).
inherited
onMissionStart(String missionId) → Future<void>
Called once before the mission starts.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited