[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6PF6WF4WHX3V8BQH18R08HD":3,"skill-same:01M6PF6WF4WHX3V8BQH18R08HD":69},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":21,"linkOnly":22,"markdownContent":23,"markdownBody":24,"frontMatter":25,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M6PF6WF4WHX3V8BQH18R08HD","workflow-guide",null,"openJiuwen-ai\u002Fagent-core-java","openJiuwen-ai","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F264091041?v=4","01M6PF3SW90T9MK2B9PHFDAE9C","openJiuwen","01M6PF3T0P2A1EYWG3JACQS3MQ",49,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai\u002Fagent-core-java\u002Fblob\u002Fdevelop\u002F.claude\u002Fskills\u002Fworkflow-guide\u002FSKILL.md",[],[18,19,20],"workflow","guide","workflow guide","2026-11-10 10:12:30",false,"---\nname: workflow-guide\ndescription: Workflow application building guide. Based on the com.openjiuwen.core.workflow package, guides users to build, orchestrate, and execute a single workflow graph from scratch, as well as host multiple workflows with WorkflowAgent. Actively apply when users build workflows, use Workflow\u002FWorkflowCard\u002FWorkflowSessions, register Start\u002FEnd\u002FLLMComponent\u002FQuestionerComponent, connect edges with addConnection\u002FaddConditionalConnection\u002FaddStreamConnection, call invoke\u002Fstream, handle INPUT_REQUIRED interactive input, or do WorkflowAgent multi-workflow routing. Related keywords: workflow, WorkflowCard, WorkflowSessions, WorkflowOutput, invoke, stream, QuestionerComponent, LLMComponent, addConnection, INPUT_REQUIRED, WorkflowAgent, SubWorkflowComponentImpl. Not applicable for: agent team assembly (use agent-team-guide), single ReAct agent, discussions unrelated to workflow.\n---\n\n# Workflow Application Building Guide\n\nThis skill guides building workflow applications based on the `com.openjiuwen.core.workflow` package. Core mental model: **a workflow = an executable graph composed of nodes and edges**, executed in batch with `invoke(...)` or in streaming mode with `stream(...)`.\n\n## Core Mental Model\n\n- `Workflow` is \"an executable graph\", not a workflow list, not an intent router.\n- `WorkflowAgent` is the application-layer entry point that hosts multiple workflows and selects which one to run; `Workflow` is a single graph.\n- Registering components defines \"what the nodes are\"; connecting edges defines \"what path the nodes execute along\". **Both are required**.\n- `invoke(...)` focuses on complete results; `stream(...)` focuses on incremental output.\n- `INPUT_REQUIRED` is not a failure; it is an intermediate state meaning \"waiting for additional input\", and execution resumes by reusing the same session.\n\n## Key Concepts Quick Reference\n\n| Term | Java Type | Meaning |\n| --- | --- | --- |\n| Workflow | `Workflow` | The main workflow class exposed to users; a directed graph |\n| Workflow Card | `WorkflowCard` | Metadata: id\u002Fname\u002Fversion\u002Fdescription\u002FinputParams |\n| Start\u002FEnd Nodes | `Start` \u002F `End` | Entry node passes through input \u002F Exit node produces final result |\n| Business Nodes | `QuestionerComponent` \u002F `LLMComponent` \u002F `BranchComponent` \u002F `IntentDetectionComponent` | Actual business logic |\n| Sub-Workflow | `SubWorkflowComponentImpl` | Wraps another Workflow as a node call |\n| Normal Edge | `addConnection(...)` | Batch sequential dependency |\n| Conditional Edge | `addConditionalConnection(...)` | Runtime decision for next node (`BranchRouter` or `Function`) |\n| Streaming Edge | `addStreamConnection(...)` | Passes incremental data |\n| Workflow Session | `WorkflowSessions` \u002F `WorkflowSessionApi` | Saves execution state, shares intermediate results, handles interactive resumption |\n| Workflow Output | `WorkflowOutput` | Return container from `invoke(...)`, contains `result` + `state` |\n| Execution State | `WorkflowExecutionState` | `COMPLETED` \u002F `INPUT_REQUIRED` \u002F `ERROR` |\n| Streaming Chunk | `WorkflowChunk` \u002F `OutputSchema` | Incremental data chunk returned by `stream(...)` |\n| Interactive Input | `InteractiveInput` | Input submitted to resume execution after `INPUT_REQUIRED` |\n| Application Entry | `WorkflowAgent` | Hosts multiple workflows, performs intent recognition and routing |\n\n## Scenario Quick Reference\n\nLocate the corresponding section in this skill by task scenario:\n\n| Scenario | Go To |\n| --- | --- |\n| Build a minimal workflow from scratch | \"Quick Start: Minimal Workflow\" |\n| Build a streaming workflow | \"Quick Start: Streaming Workflow\" |\n| Handle follow-up questions \u002F interactive input | \"INPUT_REQUIRED and Interactive Resumption\" |\n| Choose invoke vs stream | \"invoke vs stream\" |\n| Implement conditional branching \u002F loops | \"Conditional Edges and Routing\" |\n| Nest sub-workflows | \"Sub-Workflow\" |\n| Host multiple workflows | \"WorkflowAgent Multi-Workflow Routing\" |\n| Choose component ability type | \"Component Ability Types (INVOKE\u002FSTREAM\u002FCOLLECT\u002FTRANSFORM)\" |\n| Understand schema reference expressions | \"Schema Reference Syntax\" |\n| Troubleshoot workflow not executing | \"Pitfall FAQ\" |\n\n## Quick Start: Minimal Workflow\n\nMinimal example: `Start -> QuestionerComponent -> End`, demonstrating follow-up questioning + execution resumption.\n\n```java\nimport com.openjiuwen.core.workflow.Workflow;\nimport com.openjiuwen.core.workflow.WorkflowCard;\nimport com.openjiuwen.core.workflow.WorkflowExecutionState;\nimport com.openjiuwen.core.workflow.WorkflowOutput;\nimport com.openjiuwen.core.workflow.WorkflowSessions;\nimport com.openjiuwen.core.workflow.component.End;\nimport com.openjiuwen.core.workflow.component.Start;\nimport com.openjiuwen.core.workflow.component.llm.*;\nimport com.openjiuwen.core.session.WorkflowSessionApi;\nimport com.openjiuwen.core.session.interaction.InteractiveInput;\n\n\u002F\u002F 1. Define card\nWorkflowCard card = WorkflowCard.builder()\n        .id(\"transfer_flow\")\n        .name(\"Transfer Service\")\n        .version(\"1.0\")\n        .description(\"Collect missing transfer amount and return final result\")\n        .inputParams(Map.of(\"type\", \"object\",\n                \"properties\", Map.of(\"query\", Map.of(\"type\", \"string\")),\n                \"required\", List.of(\"query\")))\n        .build();\n\n\u002F\u002F 2. Create Workflow and register nodes\nWorkflow workflow = new Workflow(card);\nworkflow.setStartComp(\"start\", new Start(), Map.of(\"query\", \"${query}\"), null);\n\nQuestionerConfig qConfig = new QuestionerConfig();\nqConfig.setModelClientConfig(clientConfig);\nqConfig.setModelConfig(requestConfig);\nqConfig.setQuestionContent(\"Please provide the transfer amount\");\nqConfig.setExtractFieldsFromResponse(true);\nqConfig.setFieldNames(List.of(FieldInfo.builder()\n        .fieldName(\"amount\").description(\"Transfer amount\").required(true).build()));\nqConfig.setWithChatHistory(false);\nqConfig.setMaxResponse(10);\nworkflow.addWorkflowComp(\"questioner\", new QuestionerComponent(qConfig),\n        Map.of(\"query\", \"${start.query}\"), null);\n\nworkflow.setEndComp(\"end\",\n        new End(Map.of(\"responseTemplate\", \"Transfer amount is {{amount}}\")),\n        Map.of(\"amount\", \"${questioner.amount}\"), null);\n\n\u002F\u002F 3. Connect edges (required, cannot omit)\nworkflow.addConnection(\"start\", \"questioner\");\nworkflow.addConnection(\"questioner\", \"end\");\n\n\u002F\u002F 4. Create session and execute\nWorkflowSessionApi session = WorkflowSessions.createWorkflowSession(\"conversation-001\");\nWorkflowOutput output = workflow.invoke(Map.of(\"query\", \"I want to transfer\"), session, null);\n\n\u002F\u002F 5. Handle INPUT_REQUIRED\nif (WorkflowExecutionState.INPUT_REQUIRED.equals(output.getState())) {\n    InteractiveInput reply = new InteractiveInput();\n    reply.update(\"questioner\", \"2000 yuan\");\n    output = workflow.invoke(reply, session, null);\n}\n\nif (WorkflowExecutionState.COMPLETED.equals(output.getState())) {\n    System.out.println(output.getResult());\n}\n```\n\n**Key Reminders**:\n- `${query}` reads from the workflow top-level input; `${start.query}` reads from Start output; `${questioner.amount}` reads from questioner output.\n- `addWorkflowComp(...)` only places nodes and **does not form execution order**; order is determined by `addConnection(...)`.\n- To resume execution, you must **reuse the same session**; switching sessions will lose previous state.\n\n## Quick Start: Streaming Workflow\n\nConnect `LLMComponent` incremental output to `End` via `addStreamConnection(...)`.\n\n```java\nLLMCompConfig llmConfig = new LLMCompConfig();\nllmConfig.setModelClientConfig(clientConfig);\nllmConfig.setModelConfig(requestConfig);\nllmConfig.setTemplateContent(List.of(\n        Map.of(\"role\", \"system\", \"content\", \"You are a concise assistant.\"),\n        Map.of(\"role\", \"user\", \"content\", \"{{query}}\")));\nllmConfig.setResponseFormat(Map.of(\"type\", \"text\"));\nllmConfig.setOutputConfig(Map.of(\"answer\", Map.of(\"type\", \"string\", \"required\", true)));\n\nWorkflow streamWorkflow = new Workflow();\nstreamWorkflow.setStartComp(\"start\", new Start(), Map.of(\"query\", \"${query}\"), null);\nstreamWorkflow.addWorkflowComp(\"llm\", new LLMComponent(llmConfig),\n        Map.of(\"query\", \"${start.query}\"), null);\n\n\u002F\u002F End uses streaming mode; the key is streamInputsSchema\nstreamWorkflow.setEndComp(\"end\",\n        new End(Map.of(\"responseTemplate\", \"{{answer}}\")),\n        null, null,\n        Map.of(\"answer\", \"${llm.answer}\"), null,\n        \"streaming\");\n\nstreamWorkflow.addConnection(\"start\", \"llm\");\nstreamWorkflow.addStreamConnection(\"llm\", \"end\");  \u002F\u002F Streaming edge\n\n\u002F\u002F Execute: returns synchronous Iterator\nIterator\u003CWorkflowChunk> chunks = streamWorkflow.stream(\n        Map.of(\"query\", \"Introduce Java workflows\"),\n        WorkflowSessions.createWorkflowSession(),\n        null,\n        List.of(StreamMode.OUTPUT));\n\nwhile (chunks.hasNext()) {\n    WorkflowChunk chunk = chunks.next();\n    if (chunk instanceof OutputSchema output) {\n        System.out.println(output.getPayload());\n    }\n}\n```\n\n**Key Reminders**:\n- `End` in streaming mode must declare `streamInputsSchema` (the 5th parameter), not `inputsSchema`.\n- `stream(...)` returns a **synchronous Iterator**, not an async stream.\n- `StreamMode.OUTPUT` is the most common subscription mode; there are also `TRACE` \u002F `CUSTOM`.\n\n## invoke vs stream\n\n## invoke vs stream\n\n| Invocation | Suitable Scenario | Return |\n| --- | --- | --- |\n| `invoke(...)` | Get complete result in one call; includes interactive pause and resumption | `WorkflowOutput` (result + state) |\n| `stream(...)` | Consume output incrementally while executing | `Iterator\u003CWorkflowChunk>` |\n\n## INPUT_REQUIRED and Interactive Resumption\n\nWhen `QuestionerComponent` needs to ask a follow-up question, the workflow returns `INPUT_REQUIRED`:\n\n1. Read the current interaction prompt\n2. Construct `InteractiveInput`, `reply.update(\"component_id\", \"user answer\")`\n3. **Reuse the same session** and call `workflow.invoke(reply, session, null)` again\n\n```java\nInteractiveInput reply = new InteractiveInput();\nreply.update(\"questioner\", \"2000 yuan\");  \u002F\u002F \"questioner\" must match the component id used at registration\nWorkflowOutput resumed = workflow.invoke(reply, session, null);\n```\n\n**Key**: The first parameter of `reply.update` is the **component id** (e.g., `\"questioner\"`), not the node type name. Switching sessions will lose previously accumulated state.\n\n## Conditional Edges and Routing\n\nUse `addConditionalConnection(...)` to implement runtime branching:\n\n```java\n\u002F\u002F Method 1: BranchRouter\nworkflow.addConditionalConnection(\"branch_node\", new BranchRouter(...));\n\n\u002F\u002F Method 2: Function routing\nworkflow.addConditionalConnection(\"branch_node\", (Function\u003CObject, Object>) input -> {\n    String intent = ((Map\u003CString, String>) input).get(\"intent\");\n    return switch (intent) {\n        case \"transfer\" -> \"transfer_node\";\n        case \"query\" -> \"query_node\";\n        default -> \"default_node\";\n    };\n});\n```\n\nSuitable for: conditional branching, dynamic routing, loops or back-jump scenarios.\n\n## Sub-Workflow\n\nUse `SubWorkflowComponentImpl` to wrap another `Workflow` as a node in the current graph:\n\n```java\nWorkflow subWorkflow = new Workflow(subCard);\n\u002F\u002F ... build sub-workflow\n\nworkflow.addWorkflowComp(\"sub\", new SubWorkflowComponentImpl(subWorkflow),\n        Map.of(\"input\", \"${start.input}\"), null);\nworkflow.addConnection(\"start\", \"sub\");\nworkflow.addConnection(\"sub\", \"end\");\n```\n\nBenefits: layered organization of complex processes, reusable common sub-processes, clearer visual structure.\n\n## WorkflowAgent Multi-Workflow Routing\n\n`WorkflowAgent` hosts multiple workflows at the application layer and selects which one to execute based on user intent.\n\n```java\nWorkflowAgentConfig config = WorkflowAgentConfig.builder()\n        .id(\"workflow_agent_java_example\")\n        .description(\"Java multi-workflow financial assistant example\")\n        .model(modelConfig)\n        .promptTemplate(List.of(Map.of(\"role\", \"system\", \"content\", systemPrompt)))\n        .defaultResponse(DefaultResponse.builder().text(defaultText).build())\n        .build();\n\nWorkflowAgent agent = new WorkflowAgent(config);\nagent.addWorkflows(List.of(transferWorkflow, investWorkflow, balanceWorkflow));\n```\n\n**`WorkflowEventHandler` intent recognition priority**:\n1. If the input is an `InteractiveInput` with a node id -> directly resume the interrupted workflow (no LLM intent recognition)\n2. If only one workflow is configured -> go directly to that one\n3. Multiple workflows -> LLM intent recognition to select\n4. None matched -> return `defaultResponse`\n\n`defaultResponse` is important: when intent recognition does not match, return a default reply rather than forcing a wrong business flow selection.\n\n## Component Ability Types (INVOKE\u002FSTREAM\u002FCOLLECT\u002FTRANSFORM)\n\n| Ability | Input | Output | Corresponding Method | Suitable Scenario |\n| --- | --- | --- | --- | --- |\n| `INVOKE` | batch | batch | `invoke(...)` | Normal nodes: Start, Questioner, Tool |\n| `STREAM` | batch | stream | `stream(...)` | LLM chunk-by-chunk output, ProducerNode |\n| `COLLECT` | stream | batch | `collect(...)` | Aggregate upstream multi-frame, End receives stream then returns batch |\n| `TRANSFORM` | stream | stream | `transform(...)` | Per-frame rewriting, filtering, field supplementation |\n\n**Edge Pairing**:\n- Upstream INVOKE -> Downstream INVOKE: use `addConnection`\n- Upstream STREAM\u002FTRANSFORM -> Downstream TRANSFORM\u002FCOLLECT: use `addStreamConnection`\n\n## Schema Reference Syntax\n\nUse `${...}` in node configuration to reference other nodes' output:\n\n| Syntax | Meaning |\n| --- | --- |\n| `${query}` | Read `query` from workflow top-level input |\n| `${start.query}` | Read `query` from Start node output |\n| `${questioner.amount}` | Read `amount` from questioner node output |\n| `{{amount}}` | Render variable in End's `responseTemplate` |\n\n**Note**: `inputsSchema` only describes \"where to get values\" and **does not form execution order**; execution order is determined by `addConnection(...)`.\n\n## Pitfall FAQ\n\n| Symptom | Cause | Solution |\n| --- | --- | --- |\n| Workflow does not run, nodes not executing | Only `addWorkflowComp` without `addConnection` | Add `addConnection(srcId, targetId)` |\n| Resumption after `INPUT_REQUIRED` fails, state lost | Switched to a new session | Reuse the same `WorkflowSessionApi` |\n| `reply.update(\"Questioner\", ...)` has no effect | Wrong component id (case mismatch) | id must match `addWorkflowComp(\"questioner\", ...)` |\n| Streaming `End` receives no data | Used `inputsSchema` instead of `streamInputsSchema` | In streaming mode use the 5th parameter `streamInputsSchema` |\n| `stream(...)` hangs with no data | Did not pass `StreamMode.OUTPUT` | `stream(inputs, session, null, List.of(StreamMode.OUTPUT))` |\n| Conditional edge routing returns non-existent target id | Router return value does not match registered id | Check that the router returns a string that is a registered component id |\n| `End` output template does not render | `responseTemplate` uses undefined variable | Template variables must have their source declared in `inputsSchema` |\n| Multi-workflow routing always returns default reply | Intent recognition did not match | Check workflow `description` clarity; adjust system prompt |\n\n## Usage\n\n1. **Locate scenario**: First check \"Scenario Quick Reference\" to jump to the corresponding section for the current task.\n2. **Copy template**: Code blocks in the Quick Start sections can be copied and modified directly.\n3. **Understand concepts**: If terminology is unclear, check \"Key Concepts Quick Reference\" or Read `references\u002Fkey_concepts.md`.\n4. **Component details**: When component configuration details are needed, Read `references\u002Fcomponents_guide.md`.\n5. **Real cases**: When end-to-end reference is needed, Read `references\u002Fworkflow_cases.md` (4 cases: multi-workflow financial assistant \u002F streaming Q&A \u002F multi-field follow-up \u002F conditional branching).\n6. **Multi-workflow**: When multi-workflow routing is needed, see the \"WorkflowAgent\" section.\n7. **Troubleshoot**: First check \"Pitfall FAQ\", then check component ability types and schema syntax.\n8. **Do not fabricate when uncertain**: API details should be verified against source code; this skill does not replace official API documentation.\n\n## Reference Entries\n\n- **Key Concepts In-Depth**: `references\u002Fkey_concepts.md` (Workflow\u002FWorkflowCard\u002FWorkflowSessions\u002FWorkflowOutput\u002Fexecution state\u002Fstreaming chunks\u002FInteractiveInput detailed explanation)\n- **Component Configuration Guide**: `references\u002Fcomponents_guide.md` (Start\u002FEnd\u002FQuestionerComponent\u002FLLMComponent\u002FBranchComponent configuration details + 4 ability types)\n- **Real Cases**: `references\u002Fworkflow_cases.md` (4 end-to-end cases: multi-workflow financial assistant \u002F streaming Q&A \u002F multi-field follow-up \u002F conditional branching)\n- **Minimal Runnable Example**: `references\u002FMinimalWorkflowExample.java` (self-contained, includes model configuration, copy and run)\n- Full documentation: `documents\u002Fzh\u002F2.开发指南\u002F工作流\u002F` (overview\u002Fkey concepts\u002Fbuilding workflows\u002Fusing components)\n- Example code: `examples\u002Fworkflow_agent\u002FWorkflowAgentExampleSupport.java` + `examples\u002Finteract\u002FWeatherAssistantInteractExampleSupport.java`\n- API documentation: `documents\u002Fzh\u002FAPI文档\u002Fcom.openjiuwen.core\u002Fworkflow\u002F`\n- Agent team guide: `resources\u002Fskills\u002Fagent-team-guide\u002FSKILL.md`\n","# Workflow Application Building Guide\n\nThis skill guides building workflow applications based on the `com.openjiuwen.core.workflow` package. Core mental model: **a workflow = an executable graph composed of nodes and edges**, executed in batch with `invoke(...)` or in streaming mode with `stream(...)`.\n\n## Core Mental Model\n\n- `Workflow` is \"an executable graph\", not a workflow list, not an intent router.\n- `WorkflowAgent` is the application-layer entry point that hosts multiple workflows and selects which one to run; `Workflow` is a single graph.\n- Registering components defines \"what the nodes are\"; connecting edges defines \"what path the nodes execute along\". **Both are required**.\n- `invoke(...)` focuses on complete results; `stream(...)` focuses on incremental output.\n- `INPUT_REQUIRED` is not a failure; it is an intermediate state meaning \"waiting for additional input\", and execution resumes by reusing the same session.\n\n## Key Concepts Quick Reference\n\n| Term | Java Type | Meaning |\n| --- | --- | --- |\n| Workflow | `Workflow` | The main workflow class exposed to users; a directed graph |\n| Workflow Card | `WorkflowCard` | Metadata: id\u002Fname\u002Fversion\u002Fdescription\u002FinputParams |\n| Start\u002FEnd Nodes | `Start` \u002F `End` | Entry node passes through input \u002F Exit node produces final result |\n| Business Nodes | `QuestionerComponent` \u002F `LLMComponent` \u002F `BranchComponent` \u002F `IntentDetectionComponent` | Actual business logic |\n| Sub-Workflow | `SubWorkflowComponentImpl` | Wraps another Workflow as a node call |\n| Normal Edge | `addConnection(...)` | Batch sequential dependency |\n| Conditional Edge | `addConditionalConnection(...)` | Runtime decision for next node (`BranchRouter` or `Function`) |\n| Streaming Edge | `addStreamConnection(...)` | Passes incremental data |\n| Workflow Session | `WorkflowSessions` \u002F `WorkflowSessionApi` | Saves execution state, shares intermediate results, handles interactive resumption |\n| Workflow Output | `WorkflowOutput` | Return container from `invoke(...)`, contains `result` + `state` |\n| Execution State | `WorkflowExecutionState` | `COMPLETED` \u002F `INPUT_REQUIRED` \u002F `ERROR` |\n| Streaming Chunk | `WorkflowChunk` \u002F `OutputSchema` | Incremental data chunk returned by `stream(...)` |\n| Interactive Input | `InteractiveInput` | Input submitted to resume execution after `INPUT_REQUIRED` |\n| Application Entry | `WorkflowAgent` | Hosts multiple workflows, performs intent recognition and routing |\n\n## Scenario Quick Reference\n\nLocate the corresponding section in this skill by task scenario:\n\n| Scenario | Go To |\n| --- | --- |\n| Build a minimal workflow from scratch | \"Quick Start: Minimal Workflow\" |\n| Build a streaming workflow | \"Quick Start: Streaming Workflow\" |\n| Handle follow-up questions \u002F interactive input | \"INPUT_REQUIRED and Interactive Resumption\" |\n| Choose invoke vs stream | \"invoke vs stream\" |\n| Implement conditional branching \u002F loops | \"Conditional Edges and Routing\" |\n| Nest sub-workflows | \"Sub-Workflow\" |\n| Host multiple workflows | \"WorkflowAgent Multi-Workflow Routing\" |\n| Choose component ability type | \"Component Ability Types (INVOKE\u002FSTREAM\u002FCOLLECT\u002FTRANSFORM)\" |\n| Understand schema reference expressions | \"Schema Reference Syntax\" |\n| Troubleshoot workflow not executing | \"Pitfall FAQ\" |\n\n## Quick Start: Minimal Workflow\n\nMinimal example: `Start -> QuestionerComponent -> End`, demonstrating follow-up questioning + execution resumption.\n\n```java\nimport com.openjiuwen.core.workflow.Workflow;\nimport com.openjiuwen.core.workflow.WorkflowCard;\nimport com.openjiuwen.core.workflow.WorkflowExecutionState;\nimport com.openjiuwen.core.workflow.WorkflowOutput;\nimport com.openjiuwen.core.workflow.WorkflowSessions;\nimport com.openjiuwen.core.workflow.component.End;\nimport com.openjiuwen.core.workflow.component.Start;\nimport com.openjiuwen.core.workflow.component.llm.*;\nimport com.openjiuwen.core.session.WorkflowSessionApi;\nimport com.openjiuwen.core.session.interaction.InteractiveInput;\n\n\u002F\u002F 1. Define card\nWorkflowCard card = WorkflowCard.builder()\n        .id(\"transfer_flow\")\n        .name(\"Transfer Service\")\n        .version(\"1.0\")\n        .description(\"Collect missing transfer amount and return final result\")\n        .inputParams(Map.of(\"type\", \"object\",\n                \"properties\", Map.of(\"query\", Map.of(\"type\", \"string\")),\n                \"required\", List.of(\"query\")))\n        .build();\n\n\u002F\u002F 2. Create Workflow and register nodes\nWorkflow workflow = new Workflow(card);\nworkflow.setStartComp(\"start\", new Start(), Map.of(\"query\", \"${query}\"), null);\n\nQuestionerConfig qConfig = new QuestionerConfig();\nqConfig.setModelClientConfig(clientConfig);\nqConfig.setModelConfig(requestConfig);\nqConfig.setQuestionContent(\"Please provide the transfer amount\");\nqConfig.setExtractFieldsFromResponse(true);\nqConfig.setFieldNames(List.of(FieldInfo.builder()\n        .fieldName(\"amount\").description(\"Transfer amount\").required(true).build()));\nqConfig.setWithChatHistory(false);\nqConfig.setMaxResponse(10);\nworkflow.addWorkflowComp(\"questioner\", new QuestionerComponent(qConfig),\n        Map.of(\"query\", \"${start.query}\"), null);\n\nworkflow.setEndComp(\"end\",\n        new End(Map.of(\"responseTemplate\", \"Transfer amount is {{amount}}\")),\n        Map.of(\"amount\", \"${questioner.amount}\"), null);\n\n\u002F\u002F 3. Connect edges (required, cannot omit)\nworkflow.addConnection(\"start\", \"questioner\");\nworkflow.addConnection(\"questioner\", \"end\");\n\n\u002F\u002F 4. Create session and execute\nWorkflowSessionApi session = WorkflowSessions.createWorkflowSession(\"conversation-001\");\nWorkflowOutput output = workflow.invoke(Map.of(\"query\", \"I want to transfer\"), session, null);\n\n\u002F\u002F 5. Handle INPUT_REQUIRED\nif (WorkflowExecutionState.INPUT_REQUIRED.equals(output.getState())) {\n    InteractiveInput reply = new InteractiveInput();\n    reply.update(\"questioner\", \"2000 yuan\");\n    output = workflow.invoke(reply, session, null);\n}\n\nif (WorkflowExecutionState.COMPLETED.equals(output.getState())) {\n    System.out.println(output.getResult());\n}\n```\n\n**Key Reminders**:\n- `${query}` reads from the workflow top-level input; `${start.query}` reads from Start output; `${questioner.amount}` reads from questioner output.\n- `addWorkflowComp(...)` only places nodes and **does not form execution order**; order is determined by `addConnection(...)`.\n- To resume execution, you must **reuse the same session**; switching sessions will lose previous state.\n\n## Quick Start: Streaming Workflow\n\nConnect `LLMComponent` incremental output to `End` via `addStreamConnection(...)`.\n\n```java\nLLMCompConfig llmConfig = new LLMCompConfig();\nllmConfig.setModelClientConfig(clientConfig);\nllmConfig.setModelConfig(requestConfig);\nllmConfig.setTemplateContent(List.of(\n        Map.of(\"role\", \"system\", \"content\", \"You are a concise assistant.\"),\n        Map.of(\"role\", \"user\", \"content\", \"{{query}}\")));\nllmConfig.setResponseFormat(Map.of(\"type\", \"text\"));\nllmConfig.setOutputConfig(Map.of(\"answer\", Map.of(\"type\", \"string\", \"required\", true)));\n\nWorkflow streamWorkflow = new Workflow();\nstreamWorkflow.setStartComp(\"start\", new Start(), Map.of(\"query\", \"${query}\"), null);\nstreamWorkflow.addWorkflowComp(\"llm\", new LLMComponent(llmConfig),\n        Map.of(\"query\", \"${start.query}\"), null);\n\n\u002F\u002F End uses streaming mode; the key is streamInputsSchema\nstreamWorkflow.setEndComp(\"end\",\n        new End(Map.of(\"responseTemplate\", \"{{answer}}\")),\n        null, null,\n        Map.of(\"answer\", \"${llm.answer}\"), null,\n        \"streaming\");\n\nstreamWorkflow.addConnection(\"start\", \"llm\");\nstreamWorkflow.addStreamConnection(\"llm\", \"end\");  \u002F\u002F Streaming edge\n\n\u002F\u002F Execute: returns synchronous Iterator\nIterator\u003CWorkflowChunk> chunks = streamWorkflow.stream(\n        Map.of(\"query\", \"Introduce Java workflows\"),\n        WorkflowSessions.createWorkflowSession(),\n        null,\n        List.of(StreamMode.OUTPUT));\n\nwhile (chunks.hasNext()) {\n    WorkflowChunk chunk = chunks.next();\n    if (chunk instanceof OutputSchema output) {\n        System.out.println(output.getPayload());\n    }\n}\n```\n\n**Key Reminders**:\n- `End` in streaming mode must declare `streamInputsSchema` (the 5th parameter), not `inputsSchema`.\n- `stream(...)` returns a **synchronous Iterator**, not an async stream.\n- `StreamMode.OUTPUT` is the most common subscription mode; there are also `TRACE` \u002F `CUSTOM`.\n\n## invoke vs stream\n\n## invoke vs stream\n\n| Invocation | Suitable Scenario | Return |\n| --- | --- | --- |\n| `invoke(...)` | Get complete result in one call; includes interactive pause and resumption | `WorkflowOutput` (result + state) |\n| `stream(...)` | Consume output incrementally while executing | `Iterator\u003CWorkflowChunk>` |\n\n## INPUT_REQUIRED and Interactive Resumption\n\nWhen `QuestionerComponent` needs to ask a follow-up question, the workflow returns `INPUT_REQUIRED`:\n\n1. Read the current interaction prompt\n2. Construct `InteractiveInput`, `reply.update(\"component_id\", \"user answer\")`\n3. **Reuse the same session** and call `workflow.invoke(reply, session, null)` again\n\n```java\nInteractiveInput reply = new InteractiveInput();\nreply.update(\"questioner\", \"2000 yuan\");  \u002F\u002F \"questioner\" must match the component id used at registration\nWorkflowOutput resumed = workflow.invoke(reply, session, null);\n```\n\n**Key**: The first parameter of `reply.update` is the **component id** (e.g., `\"questioner\"`), not the node type name. Switching sessions will lose previously accumulated state.\n\n## Conditional Edges and Routing\n\nUse `addConditionalConnection(...)` to implement runtime branching:\n\n```java\n\u002F\u002F Method 1: BranchRouter\nworkflow.addConditionalConnection(\"branch_node\", new BranchRouter(...));\n\n\u002F\u002F Method 2: Function routing\nworkflow.addConditionalConnection(\"branch_node\", (Function\u003CObject, Object>) input -> {\n    String intent = ((Map\u003CString, String>) input).get(\"intent\");\n    return switch (intent) {\n        case \"transfer\" -> \"transfer_node\";\n        case \"query\" -> \"query_node\";\n        default -> \"default_node\";\n    };\n});\n```\n\nSuitable for: conditional branching, dynamic routing, loops or back-jump scenarios.\n\n## Sub-Workflow\n\nUse `SubWorkflowComponentImpl` to wrap another `Workflow` as a node in the current graph:\n\n```java\nWorkflow subWorkflow = new Workflow(subCard);\n\u002F\u002F ... build sub-workflow\n\nworkflow.addWorkflowComp(\"sub\", new SubWorkflowComponentImpl(subWorkflow),\n        Map.of(\"input\", \"${start.input}\"), null);\nworkflow.addConnection(\"start\", \"sub\");\nworkflow.addConnection(\"sub\", \"end\");\n```\n\nBenefits: layered organization of complex processes, reusable common sub-processes, clearer visual structure.\n\n## WorkflowAgent Multi-Workflow Routing\n\n`WorkflowAgent` hosts multiple workflows at the application layer and selects which one to execute based on user intent.\n\n```java\nWorkflowAgentConfig config = WorkflowAgentConfig.builder()\n        .id(\"workflow_agent_java_example\")\n        .description(\"Java multi-workflow financial assistant example\")\n        .model(modelConfig)\n        .promptTemplate(List.of(Map.of(\"role\", \"system\", \"content\", systemPrompt)))\n        .defaultResponse(DefaultResponse.builder().text(defaultText).build())\n        .build();\n\nWorkflowAgent agent = new WorkflowAgent(config);\nagent.addWorkflows(List.of(transferWorkflow, investWorkflow, balanceWorkflow));\n```\n\n**`WorkflowEventHandler` intent recognition priority**:\n1. If the input is an `InteractiveInput` with a node id -> directly resume the interrupted workflow (no LLM intent recognition)\n2. If only one workflow is configured -> go directly to that one\n3. Multiple workflows -> LLM intent recognition to select\n4. None matched -> return `defaultResponse`\n\n`defaultResponse` is important: when intent recognition does not match, return a default reply rather than forcing a wrong business flow selection.\n\n## Component Ability Types (INVOKE\u002FSTREAM\u002FCOLLECT\u002FTRANSFORM)\n\n| Ability | Input | Output | Corresponding Method | Suitable Scenario |\n| --- | --- | --- | --- | --- |\n| `INVOKE` | batch | batch | `invoke(...)` | Normal nodes: Start, Questioner, Tool |\n| `STREAM` | batch | stream | `stream(...)` | LLM chunk-by-chunk output, ProducerNode |\n| `COLLECT` | stream | batch | `collect(...)` | Aggregate upstream multi-frame, End receives stream then returns batch |\n| `TRANSFORM` | stream | stream | `transform(...)` | Per-frame rewriting, filtering, field supplementation |\n\n**Edge Pairing**:\n- Upstream INVOKE -> Downstream INVOKE: use `addConnection`\n- Upstream STREAM\u002FTRANSFORM -> Downstream TRANSFORM\u002FCOLLECT: use `addStreamConnection`\n\n## Schema Reference Syntax\n\nUse `${...}` in node configuration to reference other nodes' output:\n\n| Syntax | Meaning |\n| --- | --- |\n| `${query}` | Read `query` from workflow top-level input |\n| `${start.query}` | Read `query` from Start node output |\n| `${questioner.amount}` | Read `amount` from questioner node output |\n| `{{amount}}` | Render variable in End's `responseTemplate` |\n\n**Note**: `inputsSchema` only describes \"where to get values\" and **does not form execution order**; execution order is determined by `addConnection(...)`.\n\n## Pitfall FAQ\n\n| Symptom | Cause | Solution |\n| --- | --- | --- |\n| Workflow does not run, nodes not executing | Only `addWorkflowComp` without `addConnection` | Add `addConnection(srcId, targetId)` |\n| Resumption after `INPUT_REQUIRED` fails, state lost | Switched to a new session | Reuse the same `WorkflowSessionApi` |\n| `reply.update(\"Questioner\", ...)` has no effect | Wrong component id (case mismatch) | id must match `addWorkflowComp(\"questioner\", ...)` |\n| Streaming `End` receives no data | Used `inputsSchema` instead of `streamInputsSchema` | In streaming mode use the 5th parameter `streamInputsSchema` |\n| `stream(...)` hangs with no data | Did not pass `StreamMode.OUTPUT` | `stream(inputs, session, null, List.of(StreamMode.OUTPUT))` |\n| Conditional edge routing returns non-existent target id | Router return value does not match registered id | Check that the router returns a string that is a registered component id |\n| `End` output template does not render | `responseTemplate` uses undefined variable | Template variables must have their source declared in `inputsSchema` |\n| Multi-workflow routing always returns default reply | Intent recognition did not match | Check workflow `description` clarity; adjust system prompt |\n\n## Usage\n\n1. **Locate scenario**: First check \"Scenario Quick Reference\" to jump to the corresponding section for the current task.\n2. **Copy template**: Code blocks in the Quick Start sections can be copied and modified directly.\n3. **Understand concepts**: If terminology is unclear, check \"Key Concepts Quick Reference\" or Read `references\u002Fkey_concepts.md`.\n4. **Component details**: When component configuration details are needed, Read `references\u002Fcomponents_guide.md`.\n5. **Real cases**: When end-to-end reference is needed, Read `references\u002Fworkflow_cases.md` (4 cases: multi-workflow financial assistant \u002F streaming Q&A \u002F multi-field follow-up \u002F conditional branching).\n6. **Multi-workflow**: When multi-workflow routing is needed, see the \"WorkflowAgent\" section.\n7. **Troubleshoot**: First check \"Pitfall FAQ\", then check component ability types and schema syntax.\n8. **Do not fabricate when uncertain**: API details should be verified against source code; this skill does not replace official API documentation.\n\n## Reference Entries\n\n- **Key Concepts In-Depth**: `references\u002Fkey_concepts.md` (Workflow\u002FWorkflowCard\u002FWorkflowSessions\u002FWorkflowOutput\u002Fexecution state\u002Fstreaming chunks\u002FInteractiveInput detailed explanation)\n- **Component Configuration Guide**: `references\u002Fcomponents_guide.md` (Start\u002FEnd\u002FQuestionerComponent\u002FLLMComponent\u002FBranchComponent configuration details + 4 ability types)\n- **Real Cases**: `references\u002Fworkflow_cases.md` (4 end-to-end cases: multi-workflow financial assistant \u002F streaming Q&A \u002F multi-field follow-up \u002F conditional branching)\n- **Minimal Runnable Example**: `references\u002FMinimalWorkflowExample.java` (self-contained, includes model configuration, copy and run)\n- Full documentation: `documents\u002Fzh\u002F2.开发指南\u002F工作流\u002F` (overview\u002Fkey concepts\u002Fbuilding workflows\u002Fusing components)\n- Example code: `examples\u002Fworkflow_agent\u002FWorkflowAgentExampleSupport.java` + `examples\u002Finteract\u002FWeatherAssistantInteractExampleSupport.java`\n- API documentation: `documents\u002Fzh\u002FAPI文档\u002Fcom.openjiuwen.core\u002Fworkflow\u002F`\n- Agent team guide: `resources\u002Fskills\u002Fagent-team-guide\u002FSKILL.md`\n",{},"develop","dfece20d51f9b476b87c7fc08dbba71857e1fe17",".claude\u002Fskills\u002Fworkflow-guide",10,"https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai\u002Fagent-core-java","https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai","https:\u002F\u002Fwww.openjiuwen.com","openJiuwen is an open-source community dedicated to building a production-ready AI Agent platform.","2026-11-14 13:15:45",{"source":7,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add openJiuwen-ai\u002Fagent-core-java --skill workflow-guide",{"tool":41,"command":42},"bunx","bunx skills add openJiuwen-ai\u002Fagent-core-java --skill workflow-guide",{"tool":44,"command":45},"pnpm","pnpm dlx skills add openJiuwen-ai\u002Fagent-core-java --skill workflow-guide","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai\u002Fagent-core-java\u002Fblob\u002Fdevelop\u002F.claude\u002Fskills\u002Fworkflow-guide\u002FSKILL.md",true,[49,55,59,65],{"path":50,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":53,"sourceHtmlUrl":54},"references\u002Fcomponents_guide.md","REFERENCE","参考文档",9235,"https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai\u002Fagent-core-java\u002Fblob\u002Fdevelop\u002F.claude\u002Fskills\u002Fworkflow-guide\u002Freferences\u002Fcomponents_guide.md",{"path":56,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":57,"sourceHtmlUrl":58},"references\u002Fkey_concepts.md",7951,"https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai\u002Fagent-core-java\u002Fblob\u002Fdevelop\u002F.claude\u002Fskills\u002Fworkflow-guide\u002Freferences\u002Fkey_concepts.md",{"path":60,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":64},"references\u002FMinimalWorkflowExample.java","SCRIPT","脚本",8782,"https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai\u002Fagent-core-java\u002Fblob\u002Fdevelop\u002F.claude\u002Fskills\u002Fworkflow-guide\u002Freferences\u002FMinimalWorkflowExample.java",{"path":66,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":67,"sourceHtmlUrl":68},"references\u002Fworkflow_cases.md",16110,"https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai\u002Fagent-core-java\u002Fblob\u002Fdevelop\u002F.claude\u002Fskills\u002Fworkflow-guide\u002Freferences\u002Fworkflow_cases.md",[70,89,97,107,115,123],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":21},"01M6PFBS67R67YZW9V80AHK266","web_research","Search public information and summarize sources with the search tool.","https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai\u002Fagent-core-java\u002Fblob\u002Fdevelop\u002Fexamples\u002Ftoolgroup\u002Fskills\u002Fweb_research\u002FSKILL.md",[],[77,78,79,80,81,82,83,84,85,86,87,88],"web research","research","web","with","information","sources","false","public","tool","examples","search","summarize",{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":21},"01M6PFBNC6CP2CVQE6QPJBZCT3","skill_a","Modified Skill A","https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai\u002Fagent-core-java\u002Fblob\u002Fdevelop\u002Fexamples\u002Fskill_hot_reload\u002Fskills\u002Fskill_a\u002FSKILL.md",[],[96],"skill a",{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":21},"01M6PFBHGDK865W5KFD9XC2XPB","skill_30","Skill 30 for hot-reload demo","https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai\u002Fagent-core-java\u002Fblob\u002Fdevelop\u002Fexamples\u002Fskill_hot_reload\u002Fskills\u002Fskill_30\u002FSKILL.md",[],[104,105,106],"skill 30","for","demo",{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":21},"01M6PFBDBR8BK7Z2N8XR0WV2P2","skill_29","Skill 29 for hot-reload demo","https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai\u002Fagent-core-java\u002Fblob\u002Fdevelop\u002Fexamples\u002Fskill_hot_reload\u002Fskills\u002Fskill_29\u002FSKILL.md",[],[114,105,106],"skill 29",{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":21},"01M6PFB9H4ND4RVTPBVC32CPZZ","skill_28","Skill 28 for hot-reload demo","https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai\u002Fagent-core-java\u002Fblob\u002Fdevelop\u002Fexamples\u002Fskill_hot_reload\u002Fskills\u002Fskill_28\u002FSKILL.md",[],[122,105,106],"skill 28",{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":127,"categories":128,"keywords":129,"publishedAt":21},"01M6PFB5FR4ACYQ2NCGJ51NSJT","skill_27","Skill 27 for hot-reload demo","https:\u002F\u002Fgithub.com\u002FopenJiuwen-ai\u002Fagent-core-java\u002Fblob\u002Fdevelop\u002Fexamples\u002Fskill_hot_reload\u002Fskills\u002Fskill_27\u002FSKILL.md",[],[130,106,105],"skill 27"]