fix(api-server): emit chat tool completion progress#16591
Closed
loulin wants to merge 1 commit into
Closed
Conversation
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Emit structured
hermes.tool.progresscompletion events from the OpenAI-compatible/v1/chat/completionsstreaming endpoint.The Responses API path already receives exact tool lifecycle callbacks. The chat completions streaming path only forwarded legacy start-style progress, so API Server clients could show a tool as running until the final assistant response ended. This change wires
tool_start_callbackandtool_complete_callbackinto the chat stream and includes a stabletoolCallIdon both running and completed events.Related Issue
Fixes #16588
Type of Change
Changes Made
gateway/platforms/api_server.py: adds a shared queue helper for chat-completion tool progress events and wirestool_start_callback/tool_complete_callbackinto_run_agent.tests/gateway/test_api_server.py: updates streaming tool-progress tests to asserttoolCallIdand running status, and adds coverage for completed progress with output before the final assistant content.How to Test
scripts/run_tests.sh tests/gateway/test_api_server.py -k 'tool_progress or tool_completed_progress'.scripts/run_tests.sh tests/gateway/test_api_server.py.git diff --check HEAD~1..HEAD.Targeted verification on macOS 15 / Python 3.12.10:
scripts/run_tests.sh tests/gateway/test_api_server.py -k 'tool_progress or tool_completed_progress': 3 passed, 3 warnings.scripts/run_tests.sh tests/gateway/test_api_server.py: 120 passed, 78 warnings.git diff --check HEAD~1..HEAD: passed.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — N/Acli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AFor New Skills
N/A
Screenshots / Logs
Not applicable. The behavior is covered by the streaming SSE assertions in
tests/gateway/test_api_server.py.