{"record":{"id":"9197ce52d8d2f228","repo":"alibaba/spring-ai-alibaba","slug":"sub-agent-has-no-outputkey-defined-this-may","errorCode":null,"errorMessage":"Sub-agent '{}' has no outputKey defined. This may cause data flow issues as downstream agents won't receive data from this agent.","messagePattern":"Sub-agent '(.+?)' has no outputKey defined\\. This may cause data flow issues as downstream agents won't receive data from this agent\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/flow/agent/ParallelAgent.java","lineNumber":324,"sourceCode":"\t\t * <li>The parent agent has an outputKey defined</li>\n\t\t * <li>Sub-agents can properly handle the data flow through asAsyncNodeAction</li>\n\t\t * </ul>\n\t\t *\n\t\t * <p>\n\t\t * Note: BaseAgent doesn't have inputKey property, data flow is handled through\n\t\t * asAsyncNodeAction parameters during graph construction.\n\t\t * </p>\n\t\t */\n\t\tprivate void validateInputKeyCompatibility() {\n\t\t\t// Check if sub-agents have outputKeys defined (they will be used as input\n\t\t\t// keys for downstream agents)\n\t\t\tfor (Agent subAgent : subAgents) {\n\t\t\t\tif (!(subAgent instanceof ReactAgent)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tString subAgentOutputKey = ((ReactAgent)subAgent).getOutputKey();\n\t\t\t\tif (subAgentOutputKey == null) {\n\t\t\t\t\tlogger.warn(\"Sub-agent '{}' has no outputKey defined. This may cause data flow issues \"\n\t\t\t\t\t\t\t+ \"as downstream agents won't receive data from this agent.\", subAgent.name());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Builds the ParallelAgent instance.\n\t\t * @return the built ParallelAgent instance\n\t\t * @throws GraphStateException if agent creation fails\n\t\t */\n\t\t@Override\n\t\tpublic ParallelAgent doBuild() {\n\t\t\tvalidate();\n\t\t\treturn new ParallelAgent(this);\n\t\t}\n\n\t}\n","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/flow/agent/ParallelAgent.java#L306-L342","documentation":"During ParallelAgent validation, each sub-agent that is a ReactAgent is checked for an outputKey. A ReactAgent without outputKey stores results only in conversation messages, so downstream agents/siblings cannot read its output from state; validation logs this warning (validation itself still passes).","triggerScenarios":"ParallelAgent.validate → validateInputKeyCompatibility iterates subAgents and finds a ReactAgent whose getOutputKey() is null while parallel result aggregation/data flow between agents is expected.","commonSituations":"Sub-agent built without .outputKey(...) in the builder; agent reused in both sequential (message-passing) and parallel (state-based) contexts; copied agent config missing the outputKey after refactor.","solutions":["Set an outputKey on every ReactAgent used as a parallel sub-agent","Use ParallelResultAggregator with explicit key mapping if output keys are intentionally absent","Ignore the warning if sub-agents communicate purely via messages, not state","Add a unit test asserting each sub-agent has outputKey before building the graph"],"exampleFix":"// before\nReactAgent researchAgent = ReactAgent.builder().name(\"researcher\").model(model).build(); // no outputKey\n// after\nReactAgent researchAgent = ReactAgent.builder().name(\"researcher\").model(model).outputKey(\"research_result\").build();","handlingStrategy":"validation","validationCode":"subAgents.stream().filter(a -> a instanceof ReactAgent)\n  .map(a -> (ReactAgent) a)\n  .filter(a -> a.getOutputKey() == null)\n  .forEach(a -> { throw new IllegalStateException(\"Sub-agent missing outputKey: \" + a.name()); });","typeGuard":"static boolean hasOutputKey(Agent a) { return a instanceof ReactAgent r && r.getOutputKey() != null; }","tryCatchPattern":null,"preventionTips":["Always set outputKey when composing agents in parallel","Add a graph-construction test asserting outputKey presence for parallel sub-agents","Keep agent builders centralized so outputKey assignment isn't forgotten on copies"],"tags":["parallel-agent","output-key","data-flow"],"backgroundTag":"missing-required-config-field","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}