Files
deepseek-harness/packages/support/subagent-mock
Tianyi Cui 74502fa8c2 Structured output on the subagent seam: schema subset, capture runtime, spawn/fork support
Carved out of #170 per review feedback — the foundation the workflow tool
builds on, now standing alone on master:

- dsh-tools: the structured-output JSON Schema subset (StructuredOutputSchema,
  assertSupportedOutputSchema, validateStructuredValue) — rejects loud outside
  the enforced subset, listing every violation
- dsh-subagent: SubagentStartRequest.outputSchema / SubagentResult.structured
  become a real capability; the service rejects a schema'd request whose
  provider lacks it
- dsh-subagent-inprocess: the shared structured runtime — one global
  structured_output capture tool, a prepend final-assembly listener that
  strips the placeholder for plain agents and swaps in the run's own schema
  (plus the calling instruction as a trailing section) for structured
  children, an agent/turn-continuation veto once captured, and the
  capture/nudge loop in the run driver (structuredNudgeRetries, cancellation
  honored mid-nudge); lifetime refcounted by backends and live runs
- subagent-spawn / subagent-fork flip outputSchema: true

One deliberate divergence from the #170 revision: the backends do NOT add
'tools' to their plugin inject. Doing so deferred their apply past the todo
plugin, and the delegation tool mirrors provider lifecycle — so the
model-visible tool order of every existing prompt changed, invalidating every
recorded snapshot fixture. The runtime now gates its capture-tool registration
on tools availability itself (sync when live, a scoped inject fiber when the
Loader starts the backend first), keeping this PR byte-invisible to existing
transcripts: all 35 snapshot scenarios pass against master's fixtures
unchanged.
2026-07-06 23:29:08 +08:00
..

@deepseek-ai/dsh-subagent-mock

A scripted SubagentProvider for testing the subagent seam without a model or a real child agent — the subagent analog of dsh-llm-replay.

It lets a test drive ctx.subagents and the model-facing dsh-tool-subagent through the real cordis Loader / export path, exercising provider registration, start-time capability validation, the run lifecycle (result / cancel / dispose), and the structured-output branch — all deterministically and keylessly.

Usage

Load it as a plugin (functional shape: name/inject/Config/apply, no default). Config (all optional):

Key Default Meaning
name mock Registry name to register the provider under.
reply mock subagent reply The scripted child's final answer text.
stopReason completed The stop reason result settles with.
capabilities all true Which start-time capabilities (outputSchema/depthLimit/toolFilter) the provider advertises.
inheritsParentContext false The context contract to declare; true exercises the fork-shaped tool wording in consumer tests.
structured { reply } Structured value surfaced when a request carries an outputSchema and the capability is on.

A cancel() issued before result settles flips the stop reason to aborted, so the cancellation path is observable.