huggingface / huggingface/smolagents

[BUG] Open researcher get 400 error from litellm after planning step when using deepseek-r1 (CodeAgent)

Open
#646 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
29.4k
Forks
3k
Avg merge
17m
Merged PRs (30d)
2

Description

Describe the bug
I'm using open researcher with deepseek-r1 using litellmmodel. The CodeAgent after the planning steps would create an input message that contains two consecutive message from "assistant". See the following screenshot from the open-telemetry.

Image

The first assistant message is from the "initial_facts" step while the second assistant message was from the "initial_planning" step.

This message would cause the deepseek-r1 model to return a 400 error code.

Code to reproduce the error
open researcher with deepseek-r1 as model

Error logs (if any)

Error in generating model output:
litellm.BadRequestError: OpenAIException - Error code: 400 - {'error': {'code': 'invalid_parameter_error', 'param':
None, 'message': '<400> InternalError.Algo.InvalidParameter: An unknown error occurred due to an unsupported input
format.', 'type': 'invalid_request_error'}, 'id': 'chatcmpl-df620c7e-749a-999e-b873-bc32d7a6112a', 'request_id':
'df620c7e-749a-999e-b873-bc32d7a6112a'}

Packages version:
1.8.1

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the Open Researcher CodeAgent message construction after the initial_facts and initial_planning steps, using the reported deepseek-r1 and LiteLLM reproduction. Trace how those steps become the model input and compare the resulting message sequence with the provider's accepted format. Done means the reproduction no longer sends consecutive assistant messages and the request succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ai, backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.