Skip to content

[BUG][P2] Workflow 定义的输入输出 Schema 应参与发布校验与运行验收 #274

Closed

Description

@Aias00

已确认问题

WorkflowDefinition 暴露 inputSchema/outputSchema,但校验器只拒绝空白字符串;运行器未使用这两个字段。非法 Schema 可以进入可运行定义,缺少必填输入仍会执行工具,最终返回 COMPLETED。

代码:https://github.com/agentic-ai-java/argi/blob/b34835354b27f1f320ea8438edf2e9d170e69c84/argi-orchestration/argi-workflow-core/src/main/java/io/github/agentic/ai/workflow/WorkflowDefinitionValidator.java#L27;https://github.com/agentic-ai-java/argi/blob/b34835354b27f1f320ea8438edf2e9d170e69c84/argi-orchestration/argi-workflow-core/src/main/java/io/github/agentic/ai/workflow/WorkflowAgent.java#L218。

最小复现场景与证据

  1. 创建含一个假工具步骤的 WorkflowDefinition。
  2. inputSchema 为 {"type":"object","required":["requiredInput"]},outputSchema 为 not-a-json-schema。
  3. 使用空 inputs 构造 AgentRequest,运行 Workflow,假工具记录执行次数。

实际:outcome=COMPLETED, tool executed=1。发布/构建时也没有发现 outputSchema 不是合法 JSON Schema。

交付与验收

  • 发布或实例化时检查已声明 Schema 的语法及支持方言;未声明 Schema 的调用保持现有可用行为。
  • 明确 inputSchema/outputSchema 对应的数据边界,输入在进入步骤和发生工具副作用之前校验。
  • 最终输出不符合声明时返回明确的验证失败,不能以 COMPLETED 交付;规定挂起/恢复及子流程的适用边界。
  • 覆盖非法 Schema、缺少必填字段、类型错误、合法输入/输出、无 Schema、恢复和子流程。
  • 错误包含可定位字段和错误类型;优先复用已有校验能力,不再建设竞争的通用定义体系,也不引入 Graph/Loop。

关联与范围

关联 #197、#199、#209。该缺陷针对 Workflow 输入输出契约,不重复模型能力探测或单个 ToolCall 参数校验。

验证基线与变更约束

审阅基线:Core b34835354b27f1f320ea8438edf2e9d170e69c84 / Extensions cb2635ab2fc338e8aade28a132a15f48b4e655fc。以下为离线 stub、独立 Java 探针或候选工件编译验证的结果,不代表真实模型、外部服务或生产环境验收。

修复保持独立 ReAct/Workflow 不依赖 Graph/Loop,不向 Core 引入供应商 SDK。优先修正现有契约的执行行为;确需改变公开 API、配置或定义格式时,说明较小替代方案、收益、消费者影响、目标版本与迁移方式。不得以跳过测试或删除能力换取通过。

Activity

  1. konlue commented on Nov 8, 2026

    @konlue
    Contributor

    您好,我想认领 #274。

    方案

    • 发布/实例化时校验已声明 schema 的语法:复用 networknt(draft 2020-12,与 agent 层结构化输出同一方言,版本走根 pom 统一管理),空白拒绝保持、无 schema 行为不变。
    • 输入边界:fresh run 在进入任何步骤/工具副作用之前校验 inputs;恢复路径不重验 inputs(状态由 continuation 持有,resume 请求常不带全量输入),边界写入 javadoc 与测试。
    • 输出边界:完成出口(fresh 与 resume 汇聚)统一校验 outputs,不符时抛携带 AgentResult.OutputValidationIssue(errorCode, fieldPath, message) 的新 WorkflowValidationException 终止流,不以 COMPLETED 交付;AgentOutcome 公开 API 不动。
    • 子流程:复用父 inputs,嵌套定义的 inputSchema 是其调用方的发布期契约,不在父运行入口重复把关。
    • 顺带修两个既有 bug(workflow-core 此前无任何 suspend/resume 测试所以从未暴露):①ExecutionResult.continueWith 包装丢失挂起点快照(data=null),挂起 outcome 构造必 NPE;②恢复时 continuation 被调用两次(executeSteps/Loop 的组合 lambda 重复 resume)——真实 agent 的 resumeToken 单次有效会拒绝第二次调用;组合步骤改为接收已恢复结果,恢复期 agent 恰好调用一次(测试断言)。

    测试

    新增 WorkflowSchemaContractTest 10 用例:非法 schema(input/output)、空白回归、无 schema 行为不变、缺必填输入(工具 0 执行,即 issue 复现场景反转)、类型错误 fieldPath 可定位、合法输入输出 COMPLETED、输出违规不交付、resume 合规完成 / resume 输出违规失败、子流程发布期校验 + 父运行不受重复把关。实现前同测试跑出 5F+2E(红),实现后 workflow-core 全模块 48/48 绿(含恢复期 agent 单次调用断言)。

  2. added a commit that references this issue on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions