Harden 27 min

Harden the Handoff

Reproduce a vague coding-agent end state, then persist memory, run records, and clean handoff artifacts with Anvia.

Failure pattern

The session ends with a patch, partial evidence, generated files, one skipped test, and a vague note: “mostly ready.” The next engineer or agent must reconstruct the state.

Reproduce the failure

await agent.prompt("Continue the bug fix and summarize where we are.").send();

If state only lives in chat, it is easy to lose verified facts, rejected paths, and unresolved checks.

Successful Anvia pattern

Use Anvia memory for durable coding sessions, then require a structured handoff artifact.

import type { MemoryAppendInput, MemoryContext, MemoryStore, Message } from "@anvia/core";

class RepoMemoryStore implements MemoryStore {
  async load(context: MemoryContext): Promise<Message[]> {
    return repoRunDb.loadMessages(context.sessionId);
  }

  async append(input: MemoryAppendInput): Promise<void> {
    await repoRunDb.appendMessages(input.context.sessionId, input.messages);
  }

  async clear(context: MemoryContext): Promise<void> {
    await repoRunDb.clearMessages(context.sessionId);
  }
}

const agent = new AgentBuilder("repo-coding-agent", model)
  .memory(new RepoMemoryStore(), { savePolicy: "turn" })
  .build();

await agent
  .session("issue_482_invite_acceptance", { userId: "engineer_17" })
  .prompt("Continue from the last verified finding.")
  .send();

Then make the final handoff structured:

const Handoff = z.object({
  currentState: z.array(z.string()),
  changedFiles: z.array(z.string()),
  verifiedEvidence: z.array(z.string()),
  skippedChecks: z.array(z.string()),
  knownRisks: z.array(z.string()),
  nextAction: z.string(),
  approvalStatus: z.enum(["draft", "ready_for_review", "approved_by_human"]),
});

Why it succeeds

Memory lets the agent continue. The handoff lets humans and future agents trust the state. They solve different problems, so a coding harness needs both.

Success check

A hardened handoff says:

  • what changed
  • what is verified
  • what is not done
  • what checks were skipped
  • what risk remains
  • what the next action is
  • whether human approval has happened

Final pattern

The Anvia coding-agent path ends with a system that does not rely on the model being careful. The harness owns boundaries, tools, execution order, traces, verification, and handoff.