run-llama/llama_index · warning · ValueError

Could not parse output: {output}

Error message

Could not parse output: {output}

What it means

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.

Source

Thrown at llama-index-core/llama_index/core/agent/react/output_parser.py:123

            )

        # An "Action" should take priority over an "Answer"
        if (
            action_idx is not None
            and answer_idx is not None
            and action_idx < answer_idx
        ):
            return parse_action_reasoning_step(output)
        elif action_idx is not None and answer_idx is None:
            return parse_action_reasoning_step(output)

        if answer_idx is not None:
            thought, answer = extract_final_response(output)
            return ResponseReasoningStep(
                thought=thought, response=answer, is_streaming=is_streaming
            )

        raise ValueError(f"Could not parse output: {output}")

    def format(self, output: str) -> str:
        """Format a query with structured output formatting instructions."""
        raise NotImplementedError

View on GitHub (pinned to afd0fef371)

Solutions

  1. Drop the batch_size argument (use default 1) when calling aput_all on stores without batching support.
  2. Override aput_all in your custom store to loop or bulk-insert: async for key, val: await self.aput(...).
  3. Use built-in stores with native async batching (e.g. RedisKVStore, MongoDBKVStore) for high-throughput async ingestion.
  4. Guard with hasattr/inspect to detect stores lacking an aput_all override before requesting batches.

Example fix

# before
await kvstore.aput_all(pairs, batch_size=100)  # NotImplementedError

# after
class MyKVStore(BaseKeyValueStore):
    async def aput_all(self, kv_pairs, collection=DEFAULT_COLLECTION, batch_size=1):
        for key, val in kv_pairs:
            await self.aput(key, val, collection=collection)
await kvstore.aput_all(pairs)
Defensive patterns

Strategy: validation

Validate before calling

from llama_index.core.storage.kvstore.types import BaseKeyValueStore
if batch_size != 1 and type(kvstore).aput_all is BaseKeyValueStore.aput_all:
    await kvstore.aput_all(kv_pairs)
else:
    await kvstore.aput_all(kv_pairs, batch_size=batch_size)

Type guard

def supports_async_batching(store) -> bool:
    return type(store).aput_all is not BaseKeyValueStore.aput_all

Try / catch

try:
    await kvstore.aput_all(pairs, batch_size=32)
except NotImplementedError:
    await kvstore.aput_all(pairs)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15). Data as JSON: /api/errors/dc3f4f0dca277355. Report an issue: GitHub.