You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am building a sequential workflow with 2 agents, the first one calls an MCP server and runs without issues. However, when the second agent tries to execute I am seeing the following error:
Invalid parameter: messages with role 'tool' must be a response to a preceeding message with 'tool_calls'.
at OpenAI.ClientPipelineExtensions.ProcessMessageAsync(ClientPipeline pipeline, PipelineMessage message, RequestOptions options)
at OpenAI.Chat.ChatClient.CompleteChatAsync(BinaryContent content, RequestOptions options)
at OpenAI.Chat.ChatClient.<>c__DisplayClass19_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at OpenAI.AsyncSseUpdateCollection`1.GetRawPagesAsync()+MoveNext()
Below is the code I am using:
var workflow = new WorkflowBuilder(agent).AddEdge(agent, jokeAgent).Build();
var messages = new List<ChatMessage> { new(ChatRole.User, $"{{ \"id\": \"123\" }}") };
StreamingRun run = await InProcessExecution.StreamAsync(workflow, messages);
await run.TrySendMessageAsync(new TurnToken(emitEvents: true));
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am building a sequential workflow with 2 agents, the first one calls an MCP server and runs without issues. However, when the second agent tries to execute I am seeing the following error:
ExecutorInvokedEvent(Executor = 2d5f9d2e5d3e4a29b8417dfad5b373e0, Data: Microsoft.Agents.AI.Workflows.TurnToken = Microsoft.Agents.AI.Workflows.TurnToken)
ExecutorFailedEvent(Executor = 2d5f9d2e5d3e4a29b8417dfad5b373e0, Data: System.ClientModel.ClientResultException = System.ClientModel.ClientResultException: HTTP 400 (invalid_request_error: )
Parameter: messages.[2].role
Invalid parameter: messages with role 'tool' must be a response to a preceeding message with 'tool_calls'.
at OpenAI.ClientPipelineExtensions.ProcessMessageAsync(ClientPipeline pipeline, PipelineMessage message, RequestOptions options)
at OpenAI.Chat.ChatClient.CompleteChatAsync(BinaryContent content, RequestOptions options)
at OpenAI.Chat.ChatClient.<>c__DisplayClass19_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at OpenAI.AsyncSseUpdateCollection`1.GetRawPagesAsync()+MoveNext()
Below is the code I am using:
Beta Was this translation helpful? Give feedback.
All reactions