{"record":{"id":"54f8bf0645213e8a","repo":"conductor-oss/conductor","slug":"error-preparing-chat-completion-task-input-s","errorCode":null,"errorMessage":"Error preparing chat completion task input: %s","messagePattern":"Error preparing chat completion task input: (.+?)","errorType":"exception","errorClass":"TerminateWorkflowException","httpStatus":null,"severity":"error","filePath":"agentspan/src/main/java/org/conductoross/conductor/ai/agentspan/runtime/ai/AgentChatCompleteTaskMapper.java","lineNumber":156,"sourceCode":"                chatCompletion.setMessages(history);\n            }\n            if (chatCompletion.getUserInput() != null && history.isEmpty()) {\n                history.add(new ChatMessage(ChatMessage.Role.user, chatCompletion.getUserInput()));\n            }\n            getHistory(workflowModel, taskModel, chatCompletion);\n            condenseIfNeeded(chatCompletion, taskModel, workflowModel);\n            updateTaskModel(chatCompletion, taskModel);\n            sanitizeMessages(chatCompletion);\n            validateRunnableConversation(chatCompletion);\n            ensureEndsWithUserMessage(chatCompletion, taskModel);\n            ensureJsonOutputUserMessage(chatCompletion);\n        } catch (Exception e) {\n            if (e instanceof TerminateWorkflowException) {\n                throw (TerminateWorkflowException) e;\n            } else {\n                log.error(\"input: {}\", taskModel.getInputData());\n                log.error(e.getMessage(), e);\n                throw new TerminateWorkflowException(\n                        String.format(\n                                \"Error preparing chat completion task input: %s\", e.getMessage()));\n            }\n        }\n        return taskModel;\n    }\n\n    /**\n     * OpenAI's JSON mode validation checks user input messages for the word \"json\".\n     * System/developer instructions are not sufficient for the Responses API.\n     */\n    private void ensureJsonOutputUserMessage(ChatCompletion chatCompletion) {\n        if (!chatCompletion.isJsonOutput()) {\n            return;\n        }\n\n        List<ChatMessage> messages = chatCompletion.getMessages();\n        if (messages == null) {","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/agentspan/src/main/java/org/conductoross/conductor/ai/agentspan/runtime/ai/AgentChatCompleteTaskMapper.java#L138-L174","documentation":"Error \"Error preparing chat completion task input: %s\" thrown in conductor-oss/conductor.","triggerScenarios":"Thrown at agentspan/src/main/java/org/conductoross/conductor/ai/agentspan/runtime/ai/AgentChatCompleteTaskMapper.java:156 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the task input parameters for the LLM chat-complete task; a null or unserializable value commonly causes this.","Ensure referenced upstream outputs exist and are of the expected type.","Look at the wrapped exception message (%s) for the concrete mapping failure."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}