Skip to content

Should the Chat trait take &mut Vec<Message> instead of Vec<Message> #1556

Closed

Description

@andyquinterom

i am implemeting a Chat Bot using rig. However, reasoning and tool calls are lost when using the high-level Chat trait.

These issues could be solved by passing a mutable reference to the chat_history.

The underlying implemetation of Chat already does this.


#[allow(refining_impl_trait)]
impl<M, P> Chat for Agent<M, P>
where
    M: CompletionModel,
    P: PromptHook<M> + 'static,
{
    #[tracing::instrument(skip(self, prompt, chat_history), fields(agent_name = self.name()))]
    async fn chat(
        &self,
        prompt: impl Into<Message> + WasmCompatSend,
        mut chat_history: Vec<Message>,
    ) -> Result<String, PromptError> {
        PromptRequest::from_agent(self, prompt)
            .with_history(&mut chat_history)
            .await
    }
}

Why not expose this?

Activity

  1. linear commented on Mar 24, 2026

    @linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions