> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentium.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Continue tasks with bounded source evidence

> Configure optional scoped recall and incremental archival summaries while keeping persistent memory, authority, and evidence validity on the host.

Keep the ordinary Agent loop for task execution. Add `HarnessRuntime.recall` when the host has bounded source discovery/read APIs, and add `taskSummary` when archived history should contribute incremental summaries. Both are optional; they do not require a built-in database or a persistent learning service.

This guide describes **Agentium 4.9.0**. Use [session history](/harness/sessions) for ordinary conversation reuse and [release and upgrade guidance](/reference/releases) for package versions and compatibility.

## Separate canonical history from request context

The harness session store owns controlled canonical history. `residentHistory` keeps bounded complete message groups in memory and writes evicted groups to a host `HistoryArchive` before committing the new boundary. Recall and summaries change the task's model request; they do not turn source content into host instructions.

| Content | Contract |
| - | - |
| Host instructions | Host-authorized system policy |
| Canonical history/archive | Complete groups, scoped references and integrity digests |
| Recall excerpts | Source ID, revision, locator, completeness and omissions |
| Incremental task summary | Source trust, evidence citations, uncertainty and a canonical coverage frontier |
| Persistent memory | Host-owned facts, access control, correction, deletion and retention |

A summary citation identifies evidence; it does not restore raw source text that was omitted from the prompt. Summary-only context and raw archive inclusion provide different evidence. Preserve uncertainty and avoid treating one task example as a project-wide requirement.

## Connect host-owned adapters

This is a complete integration factory. The application supplies a provider, archive, recall store and current-evidence verifier; it does not provision storage or run a model when constructed.

```typescript theme={null}
import type { ModelProvider } from "@agentium/core";
import {
  agentDriver, currentSessionRecallPolicy, HarnessRuntime,
  incrementalTaskSummaryPolicy, verifiedCompletionPolicy,
  type CompletionVerifier, type HistoryArchive, type RecallStore,
} from "@agentium/harness";

export function createContinuityRuntime(
  model: ModelProvider,
  archive: HistoryArchive,
  recallStore: RecallStore,
  verifier: CompletionVerifier,
) {
  return new HarnessRuntime({
    driver: agentDriver({
      name: "task-assistant", model,
      instructions: "Use supplied evidence. Preserve corrections and uncertainty.",
    }),
    models: { summary: { provider: model, options: ["maxTokens"] } },
    grants: { toolIds: [], modelRoles: ["main", "summary"] },
    budgets: { maxModelCalls: 12, maxToolCalls: 0, maxTokens: 24_000, maxRevisions: 1 },
    residentHistory: { maxMessages: 12, maxBytes: 32_768, archive },
    recall: {
      store: recallStore, policy: currentSessionRecallPolicy("current-session"),
      budget: {
        maxQueryBytes: 4096, maxQueries: 1, maxCandidates: 8,
        maxDiscoveryBytes: 8192, maxExcerpts: 4, maxExcerptBytes: 8192,
        maxSourceBytes: 32_768, maxEvidenceTokens: 4096,
        deadlineMs: 2000, validationDeadlineMs: 1000, maxValidationBytes: 8192,
      },
    },
    taskSummary: {
      policy: incrementalTaskSummaryPolicy({
        id: "task-summary", version: 1, modelRole: "summary",
        maxInputBytes: 65_536, maxOutputBytes: 8192, maxTokens: 1024,
        maxEvidenceReferences: 16, maxUncertainties: 8,
      }),
      maxInputBytes: 32_768, maxSummaryBytes: 8192, maxSummaryTokens: 1024,
      maxEvidenceReferences: 16, maxRecordBytes: 16_384, maxSummaryRecords: 8,
    },
    completionPolicy: verifiedCompletionPolicy({ verifier }),
  });
}
```

Call `runtime.run()` with verified `{ tenantId, userId }`, a session ID and optional `recallScope: { projectId, repositoryId }`. After admitted runs settle, close the session through `runtime.resources.closeSession(identity, sessionId)` and inspect cleanup diagnostics. The host retains ownership of shared provider/database clients.

## Make scope and backend capabilities truthful

`RecallStore` must advertise bounded discovery/reads, revision validation and bounded current validation. Summary-enabled recall additionally requires `canonicalArchiveReads: true`, attesting direct bounded seeks of complete canonical archive groups. Constructor checks validate declared capabilities; they cannot certify backend behavior.

`open(scope, limits)` returns a scoped `RecallSession` with `discover`, `read`, `validate` and `close`. Each operation receives its signal, deadline, remaining bytes and remaining estimated tokens. The adapter must enforce authorization and physical I/O bounds, stop backend work on abort, return truthful revisions, and close acquired resources even after cancellation.

Scope includes tenant, user and session, with optional project/repository IDs. A meaningful legacy snapshot without `memoryScope` requires `attestLegacyMemoryScope: true` after the host verifies its exact scope. This is an attestation of verified existing data and cannot bypass a mismatched scope. Do not accept caller-provided identity as authentication.

## Keep evidence whole and expose omissions

Recall budgets bound queries, candidates, discovery/source/excerpt bytes, estimated evidence tokens, latency and validation. Excerpts include completeness and omitted source/correction/negation context. Evidence is assembled whole; wrapper metadata also consumes the prompt budget.

Retrieval policy may stop, request bounded clarification or explicitly continue with uncertainty. `currentSessionRecallPolicy` stops failed/partial evidence and permits `no_accessible_evidence`; applications requiring evidence for every answer should reject that status too. Its query is the latest user text; production ranking and query formulation remain host decisions.

Allocation omissions change recall to partial. At that stage the policy must stop or explicitly continue; a clarification request returns `recall_assembly_omitted` because more input cannot repair an unchanged prompt ceiling. Summary additions advance only across complete canonical groups. Unavailable, changed or incomplete coverage stays explicit and does not silently advance a summary frontier.

Current-view validation runs before task dispatch and session commit. A backend authorization/deletion race can still occur after a validation fence; applications needing atomic publication must supply conditional publication or reconciliation across their stores. Keep `sourceViewRevision`, summary policy/version, scope and uncertainty with retained records.

## Verify completion using current facts

`CompletionVerifier.verify(candidate, ctx)` reads current host evidence such as artifact digests and test records. `verifiedCompletionPolicy()` accepts `pass`; `fail` stops by default or requests a configured revision; `unknown` always stops. Candidate claims and successful tool settlement do not prove completion.

Evidence is bounded to at most 32 entries and 8192 serialized bytes, and can be narrowed. Revisions share the original budget. New effects during revisions remain disabled unless `allowRevisionEffects: true` is explicitly configured, alongside ordinary grants and policy.

Use the optional `createHarnessEvalTarget()` adapter from `@agentium/harness/testing` with `@agentium/eval` to evaluate the actual runtime. Separate discovered/read evidence, prompt inclusion, supported answers, stale facts, abstention and scope. Failed graders retain generated output and report infrastructure failures plus valid-grade denominators; absent grades are not successes. Local recorded-provider evaluations establish contracts, without proving live-model quality gains.

## Own memory lifecycle and correction

The host decides which facts become durable memory, their validity, access, correction and forgetting. Ordinary Agent memory remains a separate path; avoid duplicate extraction when the harness owns canonical sessions. Memory injected into model requests is labeled source data and budgets its full wrapper.

`MemoryManager.rememberWithResult()` exposes acknowledgment. Its `drain()` tracks owned summary/extraction/final-write work, and `Agent.close()` drains that work before teardown. Inspect truthful drain results and `MemoryDrainError`; cancel and await active work before close. Busy/closing/closed Agents reject new admission through `AgentLifecycleError`. Failed teardown remains retryable without reopening execution, and borrowed resources remain host-owned.

See [Agent memory](/agents/memory), [storage identity migration](/memory/isolation#choose-a-persistent-key-encoding), and the [generated continuity contracts](/harness/api/continuity) before choosing adapters.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.