Skip to content

Config And Export ​

Multi-agent workflows have a serializable configuration shape for agents, edges, and settings. Treat this as a workflow definition format, not a snapshot of a running workflow.

Minimal Shape ​

json
{
  "name": "ReviewWorkflow",
  "version": "1.0.0",
  "agents": {
    "draft": {
      "agent": {
        "name": "Drafter",
        "systemInstructions": "Draft a concise answer."
      },
      "outputMode": "String",
      "outputKey": "draft"
    },
    "review": {
      "agent": {
        "name": "Reviewer",
        "systemInstructions": "Improve the draft."
      },
      "inputKey": "draft"
    }
  },
  "edges": [
    {
      "from": "draft",
      "to": "review"
    }
  ],
  "settings": {
    "maxConcurrency": 4
  }
}

Config can include:

  • workflow name, description, and version
  • agent node definitions (each node's agent is an AgentConfig)
  • per-node output mode, timeout, retry, input/output keys, input template, and run configuration
  • routing edges and declarative conditions
  • workflow settings and iteration options
  • optional conversation routing settings

An agent node's serializable AgentRunConfig may also contain harnesses overrides. Binding occurs when the node's agent is built and run, using that child agent's registered harness descriptors. Parent harness owner identities and runtime configuration bindings are never blindly forwarded.

See Configure A Harness Per Run.

Load From Config ​

csharp
var workflow = await AgentWorkflow
    .FromFile("review-workflow.json")
    .BuildAsync();

Or build from an in-memory config object:

csharp
var workflow = await new MultiAgentFactory()
    .BuildAsync(config);

Export ​

AgentWorkflowInstance.ExportConfigJson() reconstructs a config document from a built workflow.

Export is useful for inspection, tests, generated examples, and config authoring workflows. It writes each node's AgentConfig as declared, not the copy the workflow runtime registers. It does not serialize the workflow runtime, service providers, delegates, chat clients, runtime state, or in-flight execution state.

Round-Trip Boundaries ​

These pieces export cleanly:

  • config-backed agent definitions
  • node ids and regular graph edges
  • string output keys and input keys/templates
  • declarative edge conditions
  • compound conditions and regex options
  • retry, timeout, and selected node options

These pieces need care:

  • predicate edge delegates are non-serializable runtime code; export does not preserve the executable predicate, and re-importing the document does not restore it
  • executable harness dependencies and runtime configuration bindings are not serialized
  • a node's harness override requires a compatible harness registration in that node's definition
  • inline nodes (AddAgent("id", config => ...)) are runtime-only and make ExportConfigJson() fail because they do not expose a declarative AgentConfig
  • a node definition with process-local parts (WithChatClient, WithNativeFunction, WithMcp, harness instances, and similar) fails to export with RuntimeOnlyProviderConfiguration naming the path; see The Runtime And Its Agents
  • structured and union type names are represented, but workflows that depend on full Type restoration should verify import behavior in their target runtime
  • handoff target descriptions are not fully represented by the current node config shape
  • error/fallback settings exist in config/export, but execution wiring should be validated before relying on them as runtime policy
  • export uses camel-case property names

Iteration Settings ​

Prefer IterationOptions for cyclic and change-aware workflows:

json
{
  "settings": {
    "iterationOptions": {
      "maxIterations": 10,
      "enableAutoConvergence": true,
      "ignoreFieldsForChangeDetection": ["timestamp"],
      "alwaysDirtyNodes": ["refresh"]
    }
  }
}

Direct workflow execution applies settings.iterationOptions, settings.maxIterations, settings.defaultTimeout, settings.maxConcurrency, settings.enableMetrics (exposed as AgentWorkflowInstance.Metrics), and settings.streamingMode. The iteration limit is taken from fluent WithMaxIterations(...) first, then iterationOptions.maxIterations, then maxIterations; fluent WithTimeout(...) takes precedence over defaultTimeout.

Durable Execution ​

The workflow configuration shape does not contain a checkpoint-store setting. Durable execution is registered separately as an HPD Base graph activation.

Use AgentWorkflowInstance for direct in-process execution. Use HPD Base and HPD-Agent.MultiAgent.HpdBase when the workflow must survive process restart and be executed by activation workers. See Checkpointing.

Use WithSessionStore(...) with a Conversation Policy when node agent transcripts should be saved into HPD sessions and threads.

Built for production .NET agent applications.