microsoft/graphrag · error · ValueError

request_id needs to be passed as a keyword argument

Error message

request_id needs to be passed as a keyword argument

What it means

CompletionThreadRunner's _process_input helper requires a truthy request_id keyword so each completion request can be correlated with its response via the internal queue. Calling it without request_id (or with an empty string) raises ValueError immediately.

Source

Thrown at packages/graphrag-llm/graphrag_llm/threading/completion_thread_runner.py:210

        callback: ThreadedLLMCompletionResponseHandler,
    ):
        while True and not quit_process_event.is_set():
            try:
                data = output_queue.get(timeout=1)
            except Empty:
                continue
            if data is None:
                break
            request_id, response = data
            response = callback(request_id, response)

            if asyncio.iscoroutine(response):
                response = asyncio.run(response)

    def _process_input(request_id: str, **kwargs: Unpack["LLMCompletionArgs"]):
        if not request_id:
            msg = "request_id needs to be passed as a keyword argument"
            raise ValueError(msg)
        input_queue.put((request_id, kwargs))

    handle_response_thread = threading.Thread(
        target=_process_output,
        args=(quit_process_event, output_queue, response_handler),
    )
    handle_response_thread.start()

    def _cleanup():
        for _ in threads:
            input_queue.put(None)

        for thread in threads:
            while thread.is_alive():
                thread.join(timeout=1)

        output_queue.put(None)

View on GitHub (pinned to f40e9a26ce)

Solutions

  1. Pass a unique non-empty request_id keyword argument on every call
  2. If forwarding kwargs from another layer, thread request_id through the call chain explicitly
  3. Generate ids via uuid4().hex if you don't have a natural correlation id

Example fix

# before
runner(input="Summarize this", model="gpt-4")

# after
runner(request_id="job-42-item-7", input="Summarize this", model="gpt-4")
Defensive patterns

Strategy: validation

Validate before calling

request_id = request_id or uuid.uuid4().hex
assert request_id, "request_id required"
runner(request_id=request_id, **kwargs)

Type guard

null

Try / catch

try:
    runner(request_id=rid, **kwargs)
except ValueError as e:
    if 'request_id' in str(e):
        rid = uuid.uuid4().hex
        runner(request_id=rid, **kwargs)
    else:
        raise

Prevention

When it happens

Trigger: Invoking the runner's returned input function with only LLMCompletionArgs kwargs and no request_id, e.g. runner(input='hello') instead of runner(request_id='abc', input='hello').

Common situations: Migrating synchronous code that called a plain completion function, wrapping the runner in an adapter that forwards **kwargs but drops request_id, or generating request_ids that are sometimes empty strings.

Related errors


AI-assisted analysis of microsoft/graphrag@f40e9a26ce (2026-08-27). Data as JSON: /api/errors/6cb83637696d22be. Report an issue: GitHub.