Skip to content

Extend fallback input-schema validation to the DAG compilation path (#338 follow-up) #456

Description

@dgenio

Summary

Follow-up to #338 (PR #455). The new compile-time fallback-compatibility checks in compile_flow()missing_fallback_tool, fallback_unknown_target_key, fallback_type_mismatch, fallback_missing_required_input — are only exercised for linear Flows. DAGFlow fallbacks are not equivalently covered at compile time.

Background

  • Runtime is already handled. DAGFlow fallback execution routes through _apply_on_error_async (chainweaver/executor.py), which validates inputs against the fallback's own schema and records StepRecord.fallback_tool_name. So the runtime trace attribution from Investigation: validate fallback tool inputs against the fallback's input schema #338 already applies to DAGs.
  • Compile time is the gap. compile_flow() iterates flow.steps and accumulates context_fields linearly (chainweaver/compiler.py). For a DAGFlow, the set of inputs available to a step is governed by the dependency graph, not linear position — so _validate_fallback_inputs either does not run against a correct context model for DAG steps or is not invoked for them at all.
  • PR fix: validate fallback inputs against fallback schema #455 explicitly scoped "unrelated async DAG fallback behavior" out.

Proposed implementation

  1. Confirm how (and whether) compile_flow() is intended to validate DAGFlow today — the current context model assumes linear accumulation.
  2. Build the per-step available-context set from the DAG's resolved dependency order before invoking the existing _validate_fallback_inputs helper.
  3. Reuse _validate_fallback_inputs so the linear and DAG paths share one contract.

Acceptance criteria

  • Compiling a DAGFlow with an incompatible fallback (missing tool, unknown mapped key, missing required input, type mismatch) surfaces the same fallback_* CompilationErrors as the linear path.
  • A compatible DAGFlow fallback compiles clean.
  • Documented fallback semantics note that compile-time checks apply to both linear and DAG flows.

Test plan

  • DAG compiler tests mirroring TestFallbackInputCompatibility (tests/test_compiler.py).
  • An async DAG execution test asserting fallback_tool_name attribution end-to-end.

Relates to #338.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions