Skip to content

Teaching agent runtime: options and decision tree

Status: pilot direction agreed through Q17 on 2026-10-26; initial development on 2026-10-27. DSH is selected, with Pi as the fallback if issues surface. The agreed architecture is recorded in ADR-0070. The implementation and local verification are recorded below; the cluster feature remains disabled pending environment configuration and the real-paper trial.

The first user is Anton, acting on day-to-day teaching tasks. A remote model should be able to use a pod workspace for transformations such as rendering PDF pages, calling an OCR or vision API, inspecting the result, and then invoking Emergent’s domain Operations. Scratch scripts and intermediate files are task work, not maintained application code. A later teacher/admin rollout may need a different authority and access model; industrial-strength external access controls are not a v1 requirement.

  • Add a superuser mode to learner-web, teacher-portal, and admin-console, exposed by a local browser opt-in preference. It should expose a REPL connected to that app’s local browser pgwasm instance and an interface to the hosted agent. Anton clarified that the REPL is his own local superuser access to his browser database; it is not a hosted-agent tool or a server database console. The preference grants no server authority; hosted agent actions retain authenticated Operations permission checks.
  • Target Chinese hosted model providers, including DeepSeek, Alibaba/Qwen and Kimi. Start with DeepSeek. The earlier recommendation of a Claude-specific harness is superseded by this requirement. Workstation agents must also be able to use the same Emergent APIs.
  • Support substantial back-and-forth within retained Agent Sessions, persisted to the cluster’s S3-compatible storage. Conversation, files, and completed work can be restored into a fresh pod, with unfinished commands restarted from a recorded checkpoint. Active work can continue after the browser tab closes, and idle pods may stop.
  • Give the hosted agent Emergent Operations, selected outside APIs, and file-processing tools inside its pod. Anton retains his separate full machine/cluster access when necessary.
  • The first acceptance workflow is marking a handwritten exam: the original exam-paper PDF plus scans of approximately 45 completed copies, eight pages each. Anton expects to supply the PDFs later on 2026-10-26. The workflow should digitise the answers, work through the rubric with him, and produce detailed marks.
  • The current equivalent runs on Anton’s workstation, processes files in a temporary directory, and writes detailed marks into a separate Git-managed directory. The desired replacement runs in-cluster. Controller/executor agents and temporary/persistent storage are a welcome shape, with alternatives still open.
  • The first result is a Marking Bundle retained in S3 with downloadable detailed marks. Integration into Emergent’s canonical gradebook is deferred.
  • Every marked script must be individually inspectable, including every page if Anton chooses. He may inspect a subset or the entire set; the product must not limit review to flagged items or a sample. The extent of his review is his choice.
  • The pilot’s individual review interface is a script view with source scans, transcription, rubric, detailed marks and contextual chat. Directly editable score/transcription fields are not an immediate requirement.
  • A correction to one script affects that script unless Anton explicitly changes the shared rubric. A shared rubric change identifies and re-marks the affected answers across the cohort, retaining earlier results and highlighting conflicts with explicit human overrides.
  • Missing-API feature requests should stay inside Emergent; storing them in the database is acceptable. GitHub/Gitee submission is not part of the current design. This capability is important later and is deferred from the immediate marking work.
  • Use full DeepSeek Harness SDK for the first trial, with its controller and native subagents. Change harness if issues surface; Pi is the accepted fallback candidate. One pod per root Agent Session is the pilot shape.
  • Allow additional tool/library installations inside the pilot pod. Record all installations so actual usage can inform a curated toolkit and possible restrictions before wider deployment. Restrictions are later work, not a prerequisite for this personal pilot.
  • Retain sessions, original sources, transcriptions, rubric/mark revisions and bundles until explicitly deleted. Clear reconstructible scratch after checkpointing; do not expire review evidence automatically.
  • Start with a portable bundle containing structured JSON marks, readable per-script reports, a CSV summary and source PDFs/images. Provide a full download suitable for archiving or adding to the existing Git-managed output tree. Iterate on its format later; a fully database-modelled marking workflow is deferred.

The existing Operations API is the domain action boundary. Its catalogue already has HTTP and MCP transports and person-bound tokens; CONTEXT.md defines the terms. An agent runtime would sit outside that catalogue and call it. The proposed ADR also names a future native assistant and defers OAuth until external teachers need it. Its status is still proposed even though the principal transports are implemented.

Separate four choices: model provider, agent harness (model/tool loop), execution workspace (where files and scripts live), and user interface/task control. Choosing Kubernetes fixes only the workspace location, not the other three.

Shape Why consider it Main cost or mismatch
Pi SDK embedded in an Emergent Bun/TypeScript service Current SDK explicitly supports Bun, configurable shell/file tools, custom tools, MCP and Chinese providers; session JSONL can be restored Emergent owns session HTTP endpoints, job dispatch, artifact review and S3 checkpoint integration
OpenCode server in an agent pod, with Emergent MCP tools and a shell/workspace Existing headless HTTP server, typed client, session/event APIs, MCP and custom tools Coding-oriented defaults and its own local SQLite/workspace model need adapting to Emergent identity and S3 recovery
Chetter as task control plane plus Kubernetes runner pods Already provides task submission, streaming, records, multiple harnesses, and a pod per execution; repository input is optional Adds a separate server, database, runner and task model built primarily for development/GitHub workflows
Official DeepSeek Harness TypeScript SDK controlling a separate runtime, native background subagents/messaging, DeepSeek integration, MCP and session checkpoints Developer preview; released runtime requires Node, while Bun client compatibility still needs a trial; S3 persistence and pod lifecycle remain host work

Anton selected DeepSeek Harness first after the release-pinned comparison: its shipped delegation and checkpoint machinery match the controller/executor workflow. Pi remains the fallback with simpler direct Bun embedding. None of the reviewed harness documentation establishes a shipped S3 session backend. Emergent’s worker now supplies the S3 checkpoint integration.

DeepSeek Harness versus Pi: released integration contract

Section titled “DeepSeek Harness versus Pi: released integration contract”

The original comparison below was checked against dsh-v0.2.1-rc.3, released on 2026-10-23. A development recheck with bun info on 2026-10-27 found the newly published 0.2.1-rc.4 on next for both runtime and SDK, and the implementation was updated to that matching pair. Their latest tags still point at different older versions (dsh at 0.2.1-rc.2, SDK client at 0.0.1-rc.1). The client depends on exactly matching DSH. Recheck published releases before future updates rather than selecting the stale tags.

Comparison of the published rc.4 package contents against rc.3 found identical emitted SDK/protocol/server, base/SDK profiles, session JSONL/format, DeepSeek adapter and native subagent machinery used here. The relevant MCP change checks resource capabilities before requesting resource lists, improving compatibility with Emergent’s tools-only MCP server. The rc.4 GitHub tag/release was unavailable at verification time; the published SDK manifest, runtime manifest and MCP package provide the release evidence. The published manifests omit an engines field; do not infer rc.4’s declared requirement from newer master documentation. The selected Node runtime is verified by the local integration trials.

  • Application integration: DSH has a real TypeScript SDK, @deepseek-ai/dsh-sdk-client, that supervises the matching harness executable over stdio JSON-RPC. Pi instead embeds directly in the host Node/Bun process. DSH rc.3 declares Node ^22.19.0 || >=24.0.0; the newer master requirement is different. Development testing found that the SDK uses process.execPath to launch DSH, so direct Bun ownership fails. The implemented Bun service supervises a small Node sidecar that owns the official SDK. Initialization, a full tool-using turn and cold resume have passed against a local scripted provider.
  • Delegation: DSH’s full sdk profile ships subagent, subagent_fork, and send_message, with asynchronous completion, persistent child conversations and cold resume. The standard child agents run in the same runtime/process, normally sharing its workspace; they are not separate Kubernetes Jobs. Pi deliberately leaves subagents to extensions or the embedding application. DSH therefore removes useful intra-pod orchestration work for this pilot.
  • Provider behavior: DSH’s native DeepSeek adapter handles reasoning signatures on replay, capability-dependent tool/prompt updates, and image-file upload/reuse. These features justify evaluation with DeepSeek, but do not prove better OCR/marking performance than Pi.
  • Durability: DSH checkpoints before model requests and top-level tool effects and repairs interrupted turns on resume. An interrupted tool is recorded with an unknown outcome, not automatically replayed. The released backend is local JSONL. S3 archiving/rehydration must include root and child logs, durable attachments, and required workspace files. Neither harness restores live OS processes merely by resuming a conversation.
  • Completion/stop semantics: DSH run() returns at the next root idle interval; session/wait also waits for managed descendants and their summary work. The latter matters before reporting a delegated marking task complete. Rc.3 has no dedicated mid-turn cancel API; closing the runtime abandons active execution. Newer master documents client-owned approval and user-question RPC flows that are absent from rc.3 and must not be assumed available.
  • Profile choice: use full sdk for this trial. sdk-minimal omits subagents, jobs, skills and other services relevant to the proposed workflow.
  • Extra session-log upload: rc.3 shipped profiles enable the optional session-log-deepseek contributor by default. It sends an additional canonical session log with model requests, separately from ordinary model context. The documented enabled: false disables that extra upload. Emergent’s generated teaching profile applies this setting and disables the separate telemetry contributor, while retaining session recovery records in cluster storage.

Sources: release, released TypeScript SDK, released subagents, released protocol, released DeepSeek adapter, released checkpoints, released session-log configuration, Pi SDK, Pi’s deliberate omission of built-in subagents.

Official documentation checked on 2026-10-26 establishes the following:

  • DeepSeek’s deepseek-flash alias currently denotes DeepSeek-V4.1-Flash-1017 and supports both vision and tool calls. deepseek-v4-pro supports tools but does not support vision. A DeepSeek-only initial workflow can therefore inspect scanned pages; handwriting and marking quality remain untested on the actual exam.
  • DeepSeek vision accepts JPEG, PNG, GIF and WebP. Render PDF pages inside the pod. The documented image resizing means page/question crops should be compared with whole-page input during the pilot; this is an evaluation proposal, not evidence of OCR accuracy.
  • DeepSeek’s Responses endpoint is stateless and does not support previous_response_id, conversation, store, or background; built-in mcp and code_interpreter are ignored. The local harness must own conversation persistence, MCP execution and shell/tools. Provider API compatibility alone is not proof that every harness feature works unchanged.
  • The official DeepSeek-OCR model repository documents downloaded-model inference, not an established official hosted OCR endpoint. Hosted Flash vision fits the current no-self-hosting requirement. If it proves insufficient, Alibaba’s hosted qwen3.5-ocr or Kimi’s hosted vision can be evaluated as alternatives; they are not additional v1 providers by default.
  • Pi’s current repository is earendil-works/pi, and current SDK examples import @earendil-works/pi-coding-agent. Its provider documentation includes DeepSeek, Moonshot China/global, Kimi and Qwen China/global. Its SDK explicitly documents Node.js or Bun. Built-in MCP now exists; SDK embedding must install the MCP extension through its resource loader and bind extensions. Old claims that Pi lacks MCP are stale.
  • Pi supports persistent JSONL session trees and explicit session open/import/resume operations. Uploading a consistent session checkpoint and its required workspace files to S3, then restoring them before reopening the session, is a proposed host integration. It is not native S3 support or a promise that interrupted OS processes resume.

Sources: DeepSeek models, vision, tool calls, Responses; Pi SDK, providers, MCP, session format; DeepSeek Harness.

The Chetter repository exists. Its feature reference says git_url/repos are optional task inputs and lists OpenCode, Claude Code, Pi, Codex, CodeWhale and Niffler harnesses. Its execution documentation describes a Kubernetes pod per task, optional runtime class, and a workspace PVC or single-node hostPath. It explicitly calls out that gVisor does not control network egress. No reference to Chetter was found in this repository’s reachable history or the adjacent workspace repositories searched on 2026-10-26; that search cannot recover private chat history.

  • The installed @pgxsinkit/client exports replAdapter(client), backed by worker-compatible rawQuery and rawExec. All three apps already expose their current sync client through React contexts. @pgxsinkit/pgwasm-repl itself has not been added to the workspace. Normal raw SQL writes bypass the mutation journal/overlay and remain local; they are not permissioned server writes. Each app’s store contains its own provisioned and synced data, not the entire server database.
  • isPlatformAdmin already exists in domain auth. The learner sync monitor currently admits organization and platform admins; that existing diagnostic gate does not settle the new mode’s audience.
  • HTTP Operations accepts a verified user session or an Operations token. MCP accepts Operations tokens. The shared runner checks scopes/reach and audits the actor, while reach resolution reloads current grants. A hosted session must bind its actor from verified identity; embedding its UI does not itself authenticate a separate agent process.
  • Native Assessment/Attempt/Item Session/Score models and teacher grading UI exist. Teacher bulk intake of completed paper scripts and agent proposal provenance are gaps. The current Operations catalogue has no paper-intake or marking verb. Platform Bridge External Item Results require external counterpart identities and omit answers, so they do not directly represent scanned scripts and OCR evidence.
  • DocumentObjectStore supplies storage primitives. Development Helm values configure Supabase Storage with Garage as its S3 backend; this is repository configuration evidence, not a live storage check. Ordinary Content Artifacts freeze with processed Content, so mutable agent work needs its own lifecycle.

The harness, session/pod shape, recovery requirement, review interface, operational defaults and Marking Bundle boundary are agreed. The detailed processing stages and storage index implementation below are implementation proposals to test against sample evidence.

Use one pod per root Agent Session, running full DeepSeek Harness sdk under a thin TypeScript service and Node SDK sidecar. Let its controller delegate to native concurrent child agents in that pod, with separate per-script working directories. Emergent owns pod lifecycle, API identity, artifact review and S3 recovery; a separate Kubernetes executor scheduler is not necessary for the first trial. Keep explicit per-script output/completion records so chat history alone does not determine whether a paper was processed. Unknown interrupted tool outcomes need reconciliation before retrying effects. The local tool loop and restoration have been exercised; real provider/image handling still needs the configured-provider trial. Pi remains the alternative if DSH integration costs outweigh its built-in coordination.

Keep conversation state and task files durable independently of pod lifetime. Store transcripts, original scans, OCR revisions, rubric revisions, detailed marks, and workspace checkpoints in object storage. The initial implementation also keeps owner-scoped session metadata and state in S3, avoiding a new database schema for the pilot. A database index can follow later.

For the exam, the proposed stages are:

  1. Preserve the original PDFs and create a manifest associating each page with its candidate and page number. Check completeness before marking; do not assume scan order or handwritten name recognition is reliable.
  2. Render and transcribe pages, retaining links to the original page/crop and unresolved readings. Assemble answers across continuation pages. Marking workers can inspect the images as well as the transcription.
  3. Establish the rubric with Anton using a small calibration sample. Give each rubric revision an identity and pin every marking result to the rubric and transcription revisions used.
  4. Run bounded marking jobs over complete answers using the agreed rubric. Preserve item-level proposed marks, evidence, reasons, and questions needing review. Compute totals deterministically.
  5. Make every script available for individual review, with its original pages, transcription, rubric, and detailed marks. Flags and sampling may help navigation but must not hide other scripts or pages. If the rubric changes, identify affected answers and record replacement marks without overwriting the previous result or mixing rubric revisions silently.
  6. Retain the Marking Bundle and export the detailed marks. Committing accepted results to the canonical gradebook is deferred; it would need an explicit domain Operation and paper-intake design.

Installation records and environment recovery

Section titled “Installation records and environment recovery”

All installations must be recorded, including tools installed through the shell rather than a dedicated tool. The purpose is to learn which tools the work actually needs and whether restricting installations later is practical. This is a requirement for the trusted pilot, not a claim of tamper-proof auditing of arbitrary code.

Proposed implementation: retain an installation ledger with the session artifacts, initially as a structured file rather than a new database subsystem. Each attempt records the session/child agent, time, task reason, package manager or download source, requested tools, resolved versions, command, and outcome. Preserve available lockfiles and dependency inventories, including transitive dependencies. Include standalone binaries and system packages, not just Bun/Python dependencies. Record failed attempts as well as successful installations.

Record requests and outcomes mechanically where possible; the agent supplies the reason. Pair installation records with shell execution logs and environment inventory comparisons at checkpoints to detect unrecorded changes. Recording failures or unreconciled changes must be visible rather than silently presenting an incomplete inventory as complete. Verify coverage during the trial before relying on these records to justify restrictions.

Retain the base image identity, resolved dependency metadata and any required installed files or reproducible recovery instructions with the checkpoint. A recovered session must reconstruct the environment it needs rather than silently substituting newer dependencies. Install records remain durable after scratch cleanup and should accompany the exported bundle for the marking task. Repeated needs can inform later image contents; no package restriction is selected now.

Trial checks and remaining empirical inputs

Section titled “Trial checks and remaining empirical inputs”

The design questions through Q17 are settled. The next implementation step is a focused DSH compatibility trial, followed by a small real-paper marking sample before cohort processing:

  1. Verify the current matching DSH runtime/client releases, Bun-to-Node SDK integration, DeepSeek image/tool calls, native child completion and the intended session-log configuration.
  2. Run a representative file-processing task with an additional installation. Check recorded versions, dependencies, reason and outcome, including failure reporting and detection of installations made through the shell.
  3. Checkpoint root/child conversations, attachments, installation evidence and required files to S3; restore in a fresh pod and continue the task. Exercise interrupted-tool reconciliation and confirm that a closed browser does not stop active work.
  4. Verify that the local UI preference exposes the browser REPL and assistant without changing server authority, and that hosted and workstation clients can use the same permission-checked Operations.
  5. Use a small set of actual scripts to compare whole-page and cropped image transcription, calibrate the rubric, inspect every source page, make a local correction and a shared rubric revision, and export a complete bundle with deterministic totals and retained earlier results.

Scan grouping, candidate identity, exact rubric fields and handwriting quality should be established from the actual PDFs when available. Worker concurrency and a pilot API-spend limit should be set from a measured sample before a full paid cohort run. Teacher/admin rollout remains later work. These data-dependent items do not require inventing a finished grading contract before seeing the assessment.

  • apps/agent-runtime supplies the Bun HTTP worker, Node DSH sidecar, installation helper, file review/export and recovery. smoke checks actual SDK initialization. smoke:turn drives the actual SDK and bash tool against a local scripted Anthropic-SSE endpoint, checks the written file, closes the runtime and verifies prior prompt/tool/result/answer history after cold resume. smoke:delegation verifies native child execution and that completion waits through root idle, child completion and the final root summary. All passed with matching rc.4 packages and make no paid provider calls.
  • packages/agent-sessions supplies the shared Bun S3 adapter and owner/session object namespaces. Immutable objects and manifests precede the committed checkpoint pointer; confirmed content hashes avoid uploading unchanged bytes again. Runtime tests exercise failed publication, interrupted work, path validation, child-log retention and environment reconstruction records. Real Garage tests passed binary round trips, missing/deleted objects, pagination beyond 1,000 keys, and fresh-worker recovery after restarting storage. ZIP exports stream with backpressure while holding the workspace stable.
  • The API session feature derives ownership from verified identity, checks the configured personal-pilot audience, and controls per-session pods and Operations credentials. Opening a retained session inspects an existing pod without starting one; lost running pods become interrupted views. The personal pilot requires one controller process without rollout overlap; its lifecycle locks are process-local.
  • The shared console in packages/ui is mounted by thin adapters in all three apps. Chromium checks exercised opt-in persistence, authenticated previews, contextual chat, upstream CodeMirror REPL interaction and mobile layout with a mocked API/database surface. These UI checks do not establish live pgwasm-engine or provider behavior.
  • The portable marking contract validates rubric/transcription/result references, criterion bounds, exact totals and a consistent selected rubric across the cohort. Corrections append revisions; re-mark proposals identify human overrides. The exporter verifies referenced files and creates a fresh portable output directory with reports, JSON, CSV and source bytes.
  • The deployment runbook covers the tool image, application data image, required Secrets, S3 configuration, pilot Person ID and the remaining live checks. Actual handwriting quality, paid-provider behavior and cohort throughput remain empirical inputs.