Skip to main content Inicio Creadores openjiuwen-ai agent-core-java workflow-guide
workflow-guide 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/WorkflowCard/WorkflowSessions, register Start/End/LLMComponent/QuestionerComponent, connect edges with addConnection/addConditionalConnection/addStreamConnection, call invoke/stream, 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.
Ir a la instalación Skills Marketplace Descubre y explora habilidades de IA creadas por la comunidad.
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Copiar promptMostrar detalles del prompt Un comando directo omite el prompt de revisión. Revisa el origen antes de ejecutarlo.
npx skills add https://github.com/openJiuwen-ai/agent-core-java --skill workflow-guideEl comando permanece en una sola línea. Desplázate horizontalmente para revisarlo antes de copiarlo.
¿Prefieres una copia local? Descarga los archivos que SkillsMP tiene disponibles ahora.
Descargar Zip Descargando... Agent Team quick build guide. Based on the leader-teammate team framework in the com.openjiuwen.agentteams package. Automatically applied when users build, assemble, or run an agent team, configure multi-agent collaboration, use LeaderTeammateAgentTeam, write team skill code, or call team tools such as spawn_member/create_task/send_message. Related keywords: agent team, multi-agent team, leader-teammate, LeaderTeammateAgentTeam, TeamAgent, team skill, spawn_member, team assembly, multi-agent collaboration, investment-analysis-team. Not applicable to: single-agent (ReAct/Workflow) issues, pure model configuration, discussions unrelated to the agentteams package.
Ocupaciones relacionadas SOC
Basado en la clasificación ocupacional SOC
Explorador de archivos
5 archivos name workflow-guide description 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/WorkflowCard/WorkflowSessions, register Start/End/LLMComponent/QuestionerComponent, connect edges with addConnection/addConditionalConnection/addStreamConnection, call invoke/stream, 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.
Workflow Application Building Guide
This 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(...).
Core Mental Model
Workflow is "an executable graph", not a workflow list, not an intent router.
WorkflowAgent is the application-layer entry point that hosts multiple workflows and selects which one to run; Workflow is a single graph.
Registering components defines "what the nodes are"; connecting edges defines "what path the nodes execute along". Both are required .
invoke(...) focuses on complete results; stream(...) focuses on incremental output.
INPUT_REQUIRED is not a failure; it is an intermediate state meaning "waiting for additional input", and execution resumes by reusing the same session.
Key Concepts Quick Reference Term Java Type Meaning Workflow WorkflowThe main workflow class exposed to users; a directed graph Workflow Card WorkflowCardMetadata: id/name/version/description/inputParams Start/End Nodes Start / EndEntry node passes through input / Exit node produces final result Business Nodes QuestionerComponent / LLMComponent / BranchComponent / IntentDetectionComponentActual business logic Sub-Workflow SubWorkflowComponentImplWraps another Workflow as a node call Normal Edge addConnection(...)Batch sequential dependency Conditional Edge addConditionalConnection(...)Runtime decision for next node (BranchRouter or Function) Streaming Edge addStreamConnection(...)Passes incremental data Workflow Session WorkflowSessions / WorkflowSessionApiSaves execution state, shares intermediate results, handles interactive resumption Workflow Output WorkflowOutputReturn container from invoke(...), contains result + state Execution State WorkflowExecutionStateCOMPLETED / INPUT_REQUIRED / ERRORStreaming Chunk WorkflowChunk / OutputSchemaIncremental data chunk returned by stream(...) Interactive Input InteractiveInputInput submitted to resume execution after INPUT_REQUIRED Application Entry WorkflowAgentHosts multiple workflows, performs intent recognition and routing
Scenario Quick Reference Locate the corresponding section in this skill by task scenario:
Scenario Go To Build a minimal workflow from scratch "Quick Start: Minimal Workflow" Build a streaming workflow "Quick Start: Streaming Workflow" Handle follow-up questions / interactive input "INPUT_REQUIRED and Interactive Resumption" Choose invoke vs stream "invoke vs stream" Implement conditional branching / loops "Conditional Edges and Routing" Nest sub-workflows "Sub-Workflow" Host multiple workflows "WorkflowAgent Multi-Workflow Routing" Choose component ability type "Component Ability Types (INVOKE/STREAM/COLLECT/TRANSFORM)" Understand schema reference expressions "Schema Reference Syntax" Troubleshoot workflow not executing "Pitfall FAQ"
Quick Start: Minimal Workflow Minimal example: Start -> QuestionerComponent -> End, demonstrating follow-up questioning + execution resumption.
import com.openjiuwen.core.workflow.Workflow;
import com.openjiuwen.core.workflow.WorkflowCard;
import com.openjiuwen.core.workflow.WorkflowExecutionState;
import com.openjiuwen.core.workflow.WorkflowOutput;
import com.openjiuwen.core.workflow.WorkflowSessions;
import com.openjiuwen.core.workflow.component.End;
import com.openjiuwen.core.workflow.component.Start;
import com.openjiuwen.core.workflow.component.llm.*;
import com.openjiuwen.core.session.WorkflowSessionApi;
import com.openjiuwen.core.session.interaction.InteractiveInput;
WorkflowCard card = WorkflowCard.builder()
.id("transfer_flow" )
.name("Transfer Service" )
.version("1.0" )
.description("Collect missing transfer amount and return final result" )
.inputParams(Map.of("type" , "object" ,
"properties" , Map.of("query" , Map.of("type" , "string" )),
"required" , List.of("query" )))
.build();
Workflow workflow = new Workflow (card);
workflow.setStartComp("start" , new Start (), Map.of("query" , "${query}" ), null );
QuestionerConfig qConfig = new QuestionerConfig ();
qConfig.setModelClientConfig(clientConfig);
qConfig.setModelConfig(requestConfig);
qConfig.setQuestionContent("Please provide the transfer amount" );
qConfig.setExtractFieldsFromResponse(true );
qConfig.setFieldNames(List.of(FieldInfo.builder()
.fieldName("amount" ).description("Transfer amount" ).required(true ).build()));
qConfig.setWithChatHistory(false );
qConfig.setMaxResponse(10 );
workflow.addWorkflowComp("questioner" , new QuestionerComponent (qConfig),
Map.of("query" , "${start.query}" ), null );
workflow.setEndComp("end" ,
new End (Map.of("responseTemplate" , "Transfer amount is {{amount}}" )),
Map.of("amount" , "${questioner.amount}" ), null );
workflow.addConnection("start" , "questioner" );
workflow.addConnection("questioner" , "end" );
WorkflowSessionApi session = WorkflowSessions.createWorkflowSession("conversation-001" );
WorkflowOutput output = workflow.invoke(Map.of("query" , "I want to transfer" ), session, null );
if (WorkflowExecutionState.INPUT_REQUIRED.equals(output.getState())) {
InteractiveInput reply = new InteractiveInput ();
reply.update("questioner" , "2000 yuan" );
output = workflow.invoke(reply, session, null );
}
if (WorkflowExecutionState.COMPLETED.equals(output.getState())) {
System.out.println(output.getResult());
}
${query} reads from the workflow top-level input; ${start.query} reads from Start output; ${questioner.amount} reads from questioner output.
addWorkflowComp(...) only places nodes and does not form execution order ; order is determined by addConnection(...).
To resume execution, you must reuse the same session ; switching sessions will lose previous state.
Quick Start: Streaming Workflow Connect LLMComponent incremental output to End via addStreamConnection(...).
LLMCompConfig llmConfig = new LLMCompConfig ();
llmConfig.setModelClientConfig(clientConfig);
llmConfig.setModelConfig(requestConfig);
llmConfig.setTemplateContent(List.of(
Map.of("role" , "system" , "content" , "You are a concise assistant." ),
Map.of("role" , "user" , "content" , "{{query}}" )));
llmConfig.setResponseFormat(Map.of("type" , "text" ));
llmConfig.setOutputConfig(Map.of("answer" , Map.of("type" , "string" , "required" , true )));
Workflow streamWorkflow = new Workflow ();
streamWorkflow.setStartComp("start" , new Start (), Map.of("query" , "${query}" ), null );
streamWorkflow.addWorkflowComp("llm" , new LLMComponent (llmConfig),
Map.of("query" , "${start.query}" ), null );
streamWorkflow.setEndComp("end" ,
new End (Map.of("responseTemplate" , "{{answer}}" )),
null , null ,
Map.of("answer" , "${llm.answer}" ), null ,
"streaming" );
streamWorkflow.addConnection("start" , "llm" );
streamWorkflow.addStreamConnection("llm" , "end" );
Iterator<WorkflowChunk> chunks = streamWorkflow.stream(
Map.of("query" , "Introduce Java workflows" ),
WorkflowSessions.createWorkflowSession(),
null ,
List.of(StreamMode.OUTPUT));
while (chunks.hasNext()) {
WorkflowChunk chunk = chunks.next();
if (chunk instanceof OutputSchema output) {
System.out.println(output.getPayload());
}
}
End in streaming mode must declare streamInputsSchema (the 5th parameter), not inputsSchema.
stream(...) returns a synchronous Iterator , not an async stream.
StreamMode.OUTPUT is the most common subscription mode; there are also TRACE / CUSTOM.
invoke vs stream
invoke vs stream Invocation Suitable Scenario Return invoke(...)Get complete result in one call; includes interactive pause and resumption WorkflowOutput (result + state)stream(...)Consume output incrementally while executing Iterator<WorkflowChunk>
INPUT_REQUIRED and Interactive Resumption When QuestionerComponent needs to ask a follow-up question, the workflow returns INPUT_REQUIRED:
Read the current interaction prompt
Construct InteractiveInput, reply.update("component_id", "user answer")
Reuse the same session and call workflow.invoke(reply, session, null) again
InteractiveInput reply = new InteractiveInput ();
reply.update("questioner" , "2000 yuan" );
WorkflowOutput resumed = workflow.invoke(reply, session, null );
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.
Conditional Edges and Routing Use addConditionalConnection(...) to implement runtime branching:
workflow.addConditionalConnection("branch_node" , new BranchRouter (...));
workflow.addConditionalConnection("branch_node" , (Function<Object, Object>) input -> {
String intent = ((Map<String, String>) input).get("intent" );
return switch (intent) {
case "transfer" -> "transfer_node" ;
case "query" -> "query_node" ;
default -> "default_node" ;
};
});
Suitable for: conditional branching, dynamic routing, loops or back-jump scenarios.
Sub-Workflow Use SubWorkflowComponentImpl to wrap another Workflow as a node in the current graph:
Workflow subWorkflow = new Workflow (subCard);
workflow.addWorkflowComp("sub" , new SubWorkflowComponentImpl (subWorkflow),
Map.of("input" , "${start.input}" ), null );
workflow.addConnection("start" , "sub" );
workflow.addConnection("sub" , "end" );
Benefits: layered organization of complex processes, reusable common sub-processes, clearer visual structure.
WorkflowAgent Multi-Workflow Routing WorkflowAgent hosts multiple workflows at the application layer and selects which one to execute based on user intent.
WorkflowAgentConfig config = WorkflowAgentConfig.builder()
.id("workflow_agent_java_example" )
.description("Java multi-workflow financial assistant example" )
.model(modelConfig)
.promptTemplate(List.of(Map.of("role" , "system" , "content" , systemPrompt)))
.defaultResponse(DefaultResponse.builder().text(defaultText).build())
.build();
WorkflowAgent agent = new WorkflowAgent (config);
agent.addWorkflows(List.of(transferWorkflow, investWorkflow, balanceWorkflow));
WorkflowEventHandler intent recognition priority :
If the input is an InteractiveInput with a node id -> directly resume the interrupted workflow (no LLM intent recognition)
If only one workflow is configured -> go directly to that one
Multiple workflows -> LLM intent recognition to select
None matched -> return defaultResponse
defaultResponse is important: when intent recognition does not match, return a default reply rather than forcing a wrong business flow selection.
Component Ability Types (INVOKE/STREAM/COLLECT/TRANSFORM) Ability Input Output Corresponding Method Suitable Scenario INVOKEbatch batch invoke(...)Normal nodes: Start, Questioner, Tool STREAMbatch stream stream(...)LLM chunk-by-chunk output, ProducerNode COLLECTstream batch collect(...)Aggregate upstream multi-frame, End receives stream then returns batch TRANSFORMstream stream transform(...)Per-frame rewriting, filtering, field supplementation
Upstream INVOKE -> Downstream INVOKE: use addConnection
Upstream STREAM/TRANSFORM -> Downstream TRANSFORM/COLLECT: use addStreamConnection
Schema Reference Syntax Use ${...} in node configuration to reference other nodes' output:
Syntax Meaning ${query}Read query from workflow top-level input ${start.query}Read query from Start node output ${questioner.amount}Read amount from questioner node output {{amount}}Render variable in End's responseTemplate
Note : inputsSchema only describes "where to get values" and does not form execution order ; execution order is determined by addConnection(...).
Pitfall FAQ Symptom Cause Solution Workflow does not run, nodes not executing Only addWorkflowComp without addConnection Add addConnection(srcId, targetId) Resumption after INPUT_REQUIRED fails, state lost Switched to a new session Reuse the same WorkflowSessionApi reply.update("Questioner", ...) has no effectWrong component id (case mismatch) id must match addWorkflowComp("questioner", ...) Streaming End receives no data Used inputsSchema instead of streamInputsSchema In streaming mode use the 5th parameter streamInputsSchema stream(...) hangs with no dataDid not pass StreamMode.OUTPUT stream(inputs, session, null, List.of(StreamMode.OUTPUT))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 End output template does not renderresponseTemplate uses undefined variableTemplate variables must have their source declared in inputsSchema Multi-workflow routing always returns default reply Intent recognition did not match Check workflow description clarity; adjust system prompt
Usage
Locate scenario : First check "Scenario Quick Reference" to jump to the corresponding section for the current task.
Copy template : Code blocks in the Quick Start sections can be copied and modified directly.
Understand concepts : If terminology is unclear, check "Key Concepts Quick Reference" or Read references/key_concepts.md.
Component details : When component configuration details are needed, Read references/components_guide.md.
Real cases : When end-to-end reference is needed, Read references/workflow_cases.md (4 cases: multi-workflow financial assistant / streaming Q&A / multi-field follow-up / conditional branching).
Multi-workflow : When multi-workflow routing is needed, see the "WorkflowAgent" section.
Troubleshoot : First check "Pitfall FAQ", then check component ability types and schema syntax.
Do not fabricate when uncertain : API details should be verified against source code; this skill does not replace official API documentation.
Reference Entries
Key Concepts In-Depth : references/key_concepts.md (Workflow/WorkflowCard/WorkflowSessions/WorkflowOutput/execution state/streaming chunks/InteractiveInput detailed explanation)
Component Configuration Guide : references/components_guide.md (Start/End/QuestionerComponent/LLMComponent/BranchComponent configuration details + 4 ability types)
Real Cases : references/workflow_cases.md (4 end-to-end cases: multi-workflow financial assistant / streaming Q&A / multi-field follow-up / conditional branching)
Minimal Runnable Example : references/MinimalWorkflowExample.java (self-contained, includes model configuration, copy and run)
Full documentation: documents/zh/2.开发指南/工作流/ (overview/key concepts/building workflows/using components)
Example code: examples/workflow_agent/WorkflowAgentExampleSupport.java + examples/interact/WeatherAssistantInteractExampleSupport.java
API documentation: documents/zh/API文档/com.openjiuwen.core/workflow/
Agent team guide: resources/skills/agent-team-guide/SKILL.md