Skip to content

Add support for OpenAI function calling inputs in chat UI parsing#20058

Merged
daniellok-db merged 1 commit intomlflow:masterfrom
daniellok-db:chat-ui-fix
Jan 25, 2026
Merged

Add support for OpenAI function calling inputs in chat UI parsing#20058
daniellok-db merged 1 commit intomlflow:masterfrom
daniellok-db:chat-ui-fix

Conversation

@daniellok-db
Copy link
Collaborator

@daniellok-db daniellok-db commented Jan 16, 2026

Related Issues/PRs

#20054

What changes are proposed in this pull request?

The chat UI was not properly recognizing OpenAI's function calling inputs as chat messages. For example, when the input array in a span contains items like:

{
  "input": [
    {"role": "user", "content": "What is my horoscope?"},
    {"type": "reasoning", "id": "...", "summary": []},
    {"type": "function_call", "call_id": "...", "name": "get_horoscope", "arguments": "..."},
    {"type": "function_call_output", "call_id": "...", "output": "..."}
  ]
}

The UI would fail to parse these as chat messages because normalizeOpenAIResponsesInput only recognized OpenAIResponsesInputMessage items (with role and content).

This PR extends it to accept other formats such as function_call and function_call_output by reusing the existing isOpenAIResponsesOutputItem helper

How is this PR tested?

  • New unit/integration tests

Added new test cases:

  • handles input with function calls and function call outputs

The trace was generated by following the official OpenAI function calling tutorial:

https://platform.openai.com/docs/guides/function-calling

Before, no chat messages appear:

Screenshot 2026-01-22 at 9 26 53 PM Screenshot 2026-01-22 at 9 27 00 PM
Summary view Detail view

After:

Screenshot 2026-01-22 at 9 21 18 PM Screenshot 2026-01-22 at 9 21 26 PM
Summary view Detail view

Does this PR require documentation update?

  • No. You can skip the rest of this section.

Release Notes

Is this a user-facing change?

  • Yes. Give a description of this change to be included in the release notes for MLflow users.

Fixed an issue where the tracing UI would not properly display OpenAI function calling inputs as chat messages.

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionality

How should the PR be classified in the release notes? Choose one:

  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes

Should this PR be included in the next patch release?

  • Yes (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings January 16, 2026 08:15
@github-actions
Copy link
Contributor

🛠 DevTools 🛠

Install mlflow from this PR

# mlflow
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/20058/merge
# mlflow-skinny
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/20058/merge#subdirectory=libs/skinny

For Databricks, use the following command:

%sh curl -LsSf https://raw.githubusercontent.com/mlflow/mlflow/HEAD/dev/install-skinny.sh | sh -s pull/20058/merge

@github-actions github-actions bot added area/tracing MLflow Tracing and its integrations area/uiux Front-end, user experience, plotting, JavaScript, JavaScript dev server rn/bug-fix Mention under Bug Fixes in Changelogs. labels Jan 16, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the chat UI parsing to properly recognize OpenAI function calling inputs that appear in the input array alongside regular chat messages. Previously, the UI only recognized OpenAIResponsesInputMessage items (with role and content), but OpenAI's Responses API can include additional item types like function_call, function_call_output, and reasoning in the input array.

Changes:

  • Added support for parsing function call and function call output items in OpenAI Responses input arrays
  • Extended reasoning attachment logic to work with input arrays
  • Added comprehensive unit tests for the new functionality

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
mlflow/server/js/src/shared/web-shared/model-trace-explorer/chat-utils/openai.ts Added isOpenAIResponsesInputItem, normalizeOpenAIResponsesInputArrayItem, and processInputItemsWithReasoning functions to handle mixed input arrays containing messages, function calls, and reasoning items
mlflow/server/js/src/shared/web-shared/model-trace-explorer/chat-utils/openai.test.ts Added two test cases covering function calls with/without reasoning summaries in input arrays

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 16, 2026

Documentation preview for d0f9231 is available at:

More info
  • Ignore this comment if this PR does not change the documentation.
  • The preview is updated when a new commit is pushed to this PR.
  • This comment was created by this workflow run.
  • The documentation was built by this workflow run.

Signed-off-by: Daniel Lok <daniel.lok@databricks.com>
if (
isArray(input) &&
// openai inputs can consititute of output items such as function calls and function call outputs
input.every((message: unknown) => isOpenAIResponsesInputMessage(message) || isOpenAIResponsesOutputItem(message))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was going to implement some separate functions for detecting if we have function_call or function_call_output but realized it already exists in isOpenAIResponsesOutputItem.

it also does not seem to pose a problem to use normalizeOpenAIResponsesOutputItem to normalize the input as we do want them to be formatted as assistant messages (since the assistant is the one that requests the tools)

@daniellok-db daniellok-db added the team-review Trigger a team review request label Jan 22, 2026
Copy link
Collaborator

@serena-ruan serena-ruan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@daniellok-db daniellok-db added this pull request to the merge queue Jan 25, 2026
Merged via the queue into mlflow:master with commit d21f573 Jan 25, 2026
60 of 62 checks passed
@daniellok-db daniellok-db deleted the chat-ui-fix branch January 25, 2026 07:06
harupy pushed a commit to harupy/mlflow that referenced this pull request Jan 28, 2026
harupy pushed a commit to harupy/mlflow that referenced this pull request Jan 28, 2026
harupy pushed a commit that referenced this pull request Jan 28, 2026
…0058)

Signed-off-by: Daniel Lok <daniel.lok@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tracing MLflow Tracing and its integrations area/uiux Front-end, user experience, plotting, JavaScript, JavaScript dev server rn/bug-fix Mention under Bug Fixes in Changelogs. team-review Trigger a team review request v3.9.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants