{"record":{"id":"dc3f4f0dca277355","repo":"run-llama/llama_index","slug":"could-not-parse-output-output","errorCode":null,"errorMessage":"Could not parse output: {output}","messagePattern":"Could not parse output: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"llama-index-core/llama_index/core/agent/react/output_parser.py","lineNumber":123,"sourceCode":"            )\n\n        # An \"Action\" should take priority over an \"Answer\"\n        if (\n            action_idx is not None\n            and answer_idx is not None\n            and action_idx < answer_idx\n        ):\n            return parse_action_reasoning_step(output)\n        elif action_idx is not None and answer_idx is None:\n            return parse_action_reasoning_step(output)\n\n        if answer_idx is not None:\n            thought, answer = extract_final_response(output)\n            return ResponseReasoningStep(\n                thought=thought, response=answer, is_streaming=is_streaming\n            )\n\n        raise ValueError(f\"Could not parse output: {output}\")\n\n    def format(self, output: str) -> str:\n        \"\"\"Format a query with structured output formatting instructions.\"\"\"\n        raise NotImplementedError\n","sourceCodeStart":105,"sourceCodeEnd":128,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/agent/react/output_parser.py#L105-L128","documentation":"Async counterpart: BaseKeyValueStore.aput_all's default implementation rejects any batch_size != 1 with NotImplementedError, then falls back to awaiting aput per pair. Stores that never override aput_all (minimal custom stores, some integrations) cannot batch async writes.","triggerScenarios":"Awaiting kvstore.aput_all(kv_pairs, batch_size=32) on a custom KV store that only implements aput/aget/adelete; async ingestion pipelines that pass a configured batch size down to the storage layer.","commonSituations":"Custom async KVStore subclasses used under AsyncSimpleDocumentStore or async index stores; test doubles / in-memory fakes implementing only the abstract methods; porting sync stores to async without porting the batching override.","solutions":["Drop the batch_size argument (use default 1) when calling aput_all on stores without batching support.","Override aput_all in your custom store to loop or bulk-insert: async for key, val: await self.aput(...).","Use built-in stores with native async batching (e.g. RedisKVStore, MongoDBKVStore) for high-throughput async ingestion.","Guard with hasattr/inspect to detect stores lacking an aput_all override before requesting batches."],"exampleFix":"# before\nawait kvstore.aput_all(pairs, batch_size=100)  # NotImplementedError\n\n# after\nclass MyKVStore(BaseKeyValueStore):\n    async def aput_all(self, kv_pairs, collection=DEFAULT_COLLECTION, batch_size=1):\n        for key, val in kv_pairs:\n            await self.aput(key, val, collection=collection)\nawait kvstore.aput_all(pairs)","handlingStrategy":"validation","validationCode":"from llama_index.core.storage.kvstore.types import BaseKeyValueStore\nif batch_size != 1 and type(kvstore).aput_all is BaseKeyValueStore.aput_all:\n    await kvstore.aput_all(kv_pairs)\nelse:\n    await kvstore.aput_all(kv_pairs, batch_size=batch_size)","typeGuard":"def supports_async_batching(store) -> bool:\n    return type(store).aput_all is not BaseKeyValueStore.aput_all","tryCatchPattern":"try:\n    await kvstore.aput_all(pairs, batch_size=32)\nexcept NotImplementedError:\n    await kvstore.aput_all(pairs)","preventionTips":["Override aput_all in custom async stores.","Default to batch_size=1 unless the store class is known to batch.","Use built-in DB-backed stores for bulk async ingestion."],"tags":["kvstore","async","batching","not-implemented"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}