Skip to content

[Router] use call_id instead of id for matching function calls in Responses API for Harmony#13056

Merged
key4ng merged 2 commits intosgl-project:mainfrom
zhaowenzi:id_fix
Nov 12, 2025
Merged

[Router] use call_id instead of id for matching function calls in Responses API for Harmony#13056
key4ng merged 2 commits intosgl-project:mainfrom
zhaowenzi:id_fix

Conversation

@zhaowenzi
Copy link
Contributor

@zhaowenzi zhaowenzi commented Nov 11, 2025

Motivation

Fix function call matching logic in sgl-router's Responses API implementation to comply with OpenAI specification.

Currently, the router incorrectly uses the id field to match function_call and function_call_output items. According to OpenAI's Responses API spec, function_call_output only requires call_id field (where id is optional), and matching should be done via call_id.

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

for item in response.output:
    if item.type == "function_call":
        if item.name == "get_horoscope":
            # 3. Execute the function logic for get_horoscope
            horoscope = get_horoscope(json.loads(item.arguments))
            
            # 4. Provide function call results to the model
            input_list.append({
                "type": "function_call_output",
                "call_id": item.call_id,
                "output": json.dumps({
                  "horoscope": horoscope
                })
            })

Modifications

  • Updated matching logic in src/routers/grpc/harmony/responses.rs to use call_id instead of id
  • Updated matching logic in src/routers/grpc/harmony/builder.rs to use call_id instead of id

Accuracy Tests

  1. Before this fix
image
  1. After this fix
image
  1. Test with OpenAI
image

Benchmarking and Profiling

N/A

Checklist

@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@CatherineSue
Copy link
Collaborator

Since there is no ut added for this, please use Accuracy Tests section to upload the before vs after fix for this.

@CatherineSue
Copy link
Collaborator

Can you fix regular/responses as well? Otherwise, can we update PR title to indicate this is for Harmony only?

@zhaowenzi
Copy link
Contributor Author

zhaowenzi commented Nov 11, 2025

Hi @CatherineSue, I've added three screenshots to the PR description.

I think this could also fix regular/responses I am not very sure about the regular/responses. However, Harmony has another issue where 'type': 'function_call' always has the same call_id and id, though it's not urgent to fix.

Edit: updated the title

@zhaowenzi zhaowenzi changed the title [Router] use call_id instead of id for matching function calls in Responses API [Router] use call_id instead of id for matching function calls in Responses API for Harmony Nov 11, 2025
@key4ng
Copy link
Collaborator

key4ng commented Nov 11, 2025

pls run cargo +nightly fmt -- --check to fix the format otherwise lgtm

@zhaowenzi
Copy link
Contributor Author

Hi @key4ng , done

@CatherineSue
Copy link
Collaborator

It seems the fmt check still failed

@zhaowenzi zhaowenzi force-pushed the id_fix branch 2 times, most recently from 0ec467f to e1ed434 Compare November 11, 2025 19:04
@zhaowenzi
Copy link
Contributor Author

Hi @CatherineSue The fmt error came from the sgl-router/src/core/workflow/steps/worker_registration.rs file. It wasn’t caused by my changes, but I’ve run the command to format it now.

@CatherineSue
Copy link
Collaborator

Hi @CatherineSue The fmt error came from the sgl-router/src/core/workflow/steps/worker_registration.rs file. It wasn’t caused by my changes, but I’ve run the command to format it now.

I see. I think that was added by someone else. No need to change it for now.

@key4ng key4ng merged commit 7b877ab into sgl-project:main Nov 12, 2025
40 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments