pub async fn build_agent_node_handler(
merged_agents: HashMap<String, AgentConfig>,
tenant: String,
secrets: Arc<dyn SecretsManager>,
packs: Vec<Arc<PackRuntime>>,
audit_sink: Option<AuditSink>,
project_id: Option<String>,
) -> Option<Arc<dyn AgentNodeHandler>>Expand description
Build the production DwAgent handler if the environment is configured.
Returns None (so DwAgent flow dispatch errors clearly) under any of
these graceful-degradation conditions:
merged_agentsis empty (no agents from packs or operator config);GREENTIC_AW_REDIS_URLis unset/empty;- the AW Redis connection fails;
- the extension runtime fails to initialise.
merged_agents is the result of merging pack-embedded agents (base)
with operator-declared [HostConfig::agents] (operator wins on
collision). This merged map replaces the former direct read of
config.agents so pack-provided agents are included in the runtime.
Redis is sourced from the environment because the runner uses an
in-memory flow-state store by default and carries no Redis URL in
[HostConfig]; this mirrors the existing env-config convention.
The tenant and secrets arguments wire in per-tenant LLM credential
resolution when GREENTIC_AW_LLM_EXTENSION is set: requests resolve
credentials from the secrets broker for the calling tenant rather than
reading global env vars. Callers without per-tenant context (e.g.
serve_agentic) should use build_agent_runtime directly, which uses
the env-keyed backend and accepts no secrets context.
audit_sink (EPIC-B B-3) is threaded straight through to the
constructed RuntimeAgentNodeHandler; None (no NATS audit client
configured) keeps dw.agent execution on the plain
greentic_aw_runtime::AgentRuntime::step path — zero behaviour
change from before this parameter existed.
project_id is the deployed unit’s bundle_id — the value
greentic-designer records as pack_name — used as the project_id
billing dimension. Pass None when no bundle is pinned (the legacy
tenant-only pack path); billing then omits the dimension instead of
attributing spend to a non-unique agent id.