Platform Compression
Strict type-aware v2 compression behind bundle clients.
Purpose and ownership
compress.v2 compresses typed source material into summary text. The platform owns the compression
algorithm, model, prompting, billing construction, and analytics. The bundle side is a strict
transport client only — and scheduling is not the bundle's decision either: the jump-forward
workflow chooses when to compress and what to send
(see the workflow compression article); the executor forwards each
requested call here because SES workflow code cannot reach c.api itself.
compress.v1 remains available for generic text compaction.
compress.v2 adds a strict, type-aware contract and retention metadata without changing v1.
Request shape
CompressV2Args is exactly:
type CompressV2Args = {
text: string;
type:
| "paxhistoria.game-agent-stack.v1"
| "paxhistoria.catalyst-agent-stack.v1"
| "paxhistoria.chat-thread.v1"
| "paxhistoria.global-history.v1";
detailsRetained: 0.5 | 0.8 | 0.9 | 0.95;
};The platform chooses type-specific instructions. Historia currently uses the game-agent,
catalyst-agent, and chat-thread types. The global-history type remains in the generic platform
contract for compatibility; it is not part of the current Historia workflow architecture.
Callers currently request detailsRetained: 0.9; the type and retention value are included in
success metadata and telemetry.
Those policy instructions are sent as a trusted system message. Creator history text is a separate
data-only user message, so instructions embedded in history never share the policy privilege.
The call, condensed from the current client:
export async function callCompression(
gameCtx: GameContext,
args: CompressV2Args,
callId: string,
beneficiaryUserIds: readonly string[],
workflowRunId: string
): Promise<CompressV2Result> {
const wireArgs = {
text: args.text,
type: args.type,
detailsRetained: args.detailsRetained,
beneficiaryUserIds,
workflowRunId
};
const invoke = await gameCtx.apiInvoke("compress.v2", wireArgs, {
idempotencyKey: callId
});
if (!invoke.ok) throw new Error(`compress.v2 invoke failed: ${invoke.error}`);
return requireCompressV2Result(invoke.result);
}The client reconstructs wireArgs from only text, type, and detailsRetained, then adds the
canonical current non-spectator playing humans (disconnected included) and the bounded host
workflow-run identity.
It never spreads untrusted extra fields onto the wire, so workflow code cannot smuggle beneficiary
or payer fields. The workflow submits at most four calls and the executor defensively enforces the
same cap; calls are awaited sequentially, preserving request/result order. The executor mints an
opaque id for each actual invocation. The platform binds that id to the exact trusted request so an
exact transport redelivery replays, but neither side derives logical identity from text, workflow
run, or beneficiaries. Logical deduplication belongs to workflow state: the default workflow does
not call the service when its target stack transition is already durable. Internal model, prompt, and
algorithm versions are excluded from creator input; the platform freezes them at trusted acceptance
for audit and persists the exact projected URL-service response on that accepted lifecycle. Replay
returns those stored bytes without running current projection code. For a new call, the platform
revalidates the Stage-1 structure,
structure version, owner/participants, and consent immediately before provider work and
finalization. Drift returns a host-wire failure that the executor brands opaquely for creator code
instead of charging a stale payer.
Host wire result
{ ok: true, summary, meta }—metacarries themeasured_experimental.v1quality policy, token estimates, and the platform algorithm identifier.{ ok: false, errorCode, retryable, systemCard, removedPlayers }witherrorCodeinvalidationError | configurationError | billingError | providerError.
requireCompressV2Result validates this host-only envelope exactly and throws on skew. These
errorCode, retryable, systemCard, and removedPlayers fields are not creator-readable workflow
data.
The result metadata requires the exact type and detailsRetained supplied by the caller.
requireCompressV2Result rejects any service-version, type, retention, or field skew.
Creator-visible result
The jump-forward executor converts every host-wire failure and every transport/contract exception
to { ok: false, failure, call }, where failure is a branded opaque WorkflowAIError capability.
Creator workflow code may test that capability for truthiness and pass the exact object to the
failure-settlement commands, but it cannot inspect, serialize, or string-coerce the host diagnostics.
Successful calls return { ok: true, summary, meta, call }. The non-secret call record
contains the opaque invocation/correlation id; see the
workflow memory article.