Skip to content

Conversation

@oseoin
Copy link
Collaborator

@oseoin oseoin commented Jul 16, 2025

Proposed changes

Initially enure that for messages with null content and tool_calls present:

  • null content is maintained
  • tool_calls data is passed through

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have written my commit messages in the Conventional Commits format.
  • I have read the CONTRIBUTING doc
  • I have added tests (when possible) that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

@oseoin oseoin requested a review from a team as a code owner July 16, 2025 11:16
@ryan-surname-p
Copy link

ryan-surname-p commented Jul 16, 2025

will this work on response choices as well?

example response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1699896916,
  "model": "gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_abc123",
            "type": "function",
            "function": {
              "name": "get_current_weather",
              "arguments": "{\n\"location\": \"Boston, MA\"\n}"
            }
          }
        ]
      },
      "logprobs": null,
      "finish_reason": "tool_calls"
    }
  ],
  "usage": {
    "prompt_tokens": 82,
    "completion_tokens": 17,
    "total_tokens": 99,
    "completion_tokens_details": {
      "reasoning_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    }
  }
}

@oseoin
Copy link
Collaborator Author

oseoin commented Jul 16, 2025

@ryan-surname-p yes, the same Message class is used for both.

POST
http://localhost:8000/api/v1/execute/example/update-messages
user-agent:
httpyac
content-type:
multipart/form-data;boundary="boundary"
accept:
*/*
content-length:
1348
accept-encoding:
gzip, deflate, br
--boundary
Content-Disposition: form-data; name="response.parameters"
Content-Type: application/json

{ "modify": true, "add_system_prompt": true }
--boundary
Content-Disposition: form-data; name="metadata"
Content-Type: application/json

{  }
--boundary
Content-Disposition: form-data; name="response.choices"
Content-Type: application/json; charset=utf-8

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1699896916,
  "model": "gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_abc123",
            "type": "function",
            "function": {
              "name": "get_current_weather",
              "arguments": "{\n\"location\": \"Boston, MA\"\n}"
            }
          }
        ]
      },
      "logprobs": null,
      "finish_reason": "tool_calls"
    },{
      "message": {
        "content": "Hello from system",
        "role": "assistant"
      }
    }
  ],
  "usage": {
    "prompt_tokens": 82,
    "completion_tokens": 17,
    "total_tokens": 99,
    "completion_tokens_details": {
      "reasoning_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    }
  }
}
--boundary--
HTTP/1.1
200
OK
date:
Wed, 16 Jul 2025 15:58:09 GMT
server:
uvicorn
content-type:
multipart/form-data;charset=utf-8;boundary="esOJMmZsk0GOGitgkvm3IUsaFb1oPQQqwuN73n6NyPOPDyp7tozbNjQIANeuzwL1"
content-encoding:
br
vary:
Accept-Encoding
transfer-encoding:
chunked
connection:
close
--esOJMmZsk0GOGitgkvm3IUsaFb1oPQQqwuN73n6NyPOPDyp7tozbNjQIANeuzwL1
Content-Disposition: form-data; name="response.choices"
Content-Type: application/json

{
    "choices": [
        {
            "message": {
                "content": null,
                "role": "assistant",
                "tool_calls": [
                    {
                        "id": "call_abc123",
                        "type": "function",
                        "function": {
                            "name": "get_current_weather",
                            "arguments": "{\n\"location\": \"Boston, MA\"\n}"
                        }
                    }
                ]
            }
        },
        {
            "message": {
                "content": "UpdateMessagesProcessor modified the output choice: Hello from system",
                "role": "assistant"
            }
        }
    ]
}
--esOJMmZsk0GOGitgkvm3IUsaFb1oPQQqwuN73n6NyPOPDyp7tozbNjQIANeuzwL1
Content-Disposition: form-data; name="metadata"
Content-Type: application/json

{"processor_id": "example:update-messages", "processor_version": "v1", "app_details": {"description": "UpdateMessagesProcessor is a simple example of a Starlette-based processor. "}}

@oseoin oseoin force-pushed the oseoin/tools-passthrough branch from a486d92 to 9c0a9c0 Compare July 16, 2025 16:20
@oseoin oseoin merged commit 66b26cc into main Jul 16, 2025
11 checks passed
@oseoin oseoin deleted the oseoin/tools-passthrough branch July 16, 2025 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants