{"record":{"id":"0e7a695fb2d4ee23","repo":"run-llama/llama_index","slug":"code-execute-fn-must-be-provided-for-codeactagent","errorCode":null,"errorMessage":"code_execute_fn must be provided for CodeActAgent","messagePattern":"code_execute_fn must be provided for CodeActAgent","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/agent/workflow/codeact_agent.py","lineNumber":271,"sourceCode":"                    current_agent_name=self.name,\n                    thinking_delta=last_chat_response.additional_kwargs.get(\n                        \"thinking_delta\", None\n                    ),\n                )\n            )\n\n        return last_chat_response, full_response_text\n\n    async def take_step(\n        self,\n        ctx: AgentContext,\n        llm_input: List[ChatMessage],\n        tools: Sequence[BaseTool],\n        memory: BaseMemory,\n    ) -> AgentOutput:\n        \"\"\"Take a single step with the code act agent.\"\"\"\n        if not self.code_execute_fn:\n            raise ValueError(\"code_execute_fn must be provided for CodeActAgent\")\n\n        # Get current scratchpad\n        scratchpad: List[ChatMessage] = await ctx.store.get(\n            self.scratchpad_key, default=[]\n        )\n        current_llm_input = [*llm_input, *scratchpad]\n\n        # Create a system message with tool descriptions\n        tool_descriptions = self._get_tool_descriptions(tools)\n        system_prompt = self.code_act_system_prompt.format(\n            tool_descriptions=tool_descriptions\n        )\n\n        # Add or overwrite system message\n        has_system = False\n        for i, msg in enumerate(current_llm_input):\n            if msg.role.value == \"system\":\n                current_llm_input[i] = ChatMessage(role=\"system\", content=system_prompt)","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/agent/workflow/codeact_agent.py#L253-L289","documentation":"QueryEngineTool._get_query_str derives the query string from either the first positional arg or the 'input' kwarg (matching the default fn_schema). If neither is present and _resolve_input_errors is False, it raises this ValueError — the tool was called without the input the query engine needs.","triggerScenarios":"Calling query_engine_tool.call(**{'query': '...'}) (wrong kwarg name, e.g. 'query' instead of 'input'); an agent framework passing only non-positional metadata kwargs; fn_schema customized to a different field name while _get_query_str still expects input; _resolve_input_errors left False when the LLM produces malformed tool args.","commonSituations":"Hand-written agent loops that forward LLM JSON whose key is not 'input'; switching from OpenAIFunction agent (which uses input) to a custom runner; older tool metadata using 'query' key; LLM hallucinating argument names.","solutions":["Pass the query as first positional or as input=: tool.call(input='What are the sales numbers?').","Construct the tool with resolve_input_errors=True (QueryEngineTool.from_defaults(..., resolve_input_errors=True)) so unexpected kwargs are stringified instead of raising.","Align the tool's fn_schema with how you call it: a schema with an input field.","Validate tool-call payloads before dispatch: ensure 'input' in kwargs or args non-empty."],"exampleFix":"# before\ntool = QueryEngineTool.from_defaults(query_engine=engine)\ntool.call(query=\"sales numbers?\")  # ValueError: Cannot call query engine without specifying `input`\n\n# after\nresult = tool.call(input=\"sales numbers?\")\n# or make it tolerant:\n# tool = QueryEngineTool.from_defaults(query_engine=engine, resolve_input_errors=True)","handlingStrategy":"validation","validationCode":"if not args and 'input' not in kwargs:\n    if tool._resolve_input_errors:\n        kwargs['input'] = str(kwargs)\n    else:\n        raise ValueError('missing input')\nresult = tool.call(*args, **kwargs)","typeGuard":"def has_query_input(args: tuple, kwargs: dict) -> bool:\n    return len(args) > 0 or 'input' in kwargs","tryCatchPattern":"try:\n    out = tool.call(**llm_args)\nexcept ValueError as e:\n    if 'without specifying `input`' in str(e):\n        out = tool.call(input=llm_args.get('query') or str(llm_args))\n    else:\n        raise","preventionTips":["Standardize on the input kwarg or a positional query when calling QueryEngineTool.","Build the tool with resolve_input_errors=True to tolerate schema drift.","Pre-validate tool-call arguments before dispatch."],"tags":["tools","query-engine","input-validation","llama-index"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}