Skip to content

fix(api-server): emit chat tool completion progress#16591

Closed
loulin wants to merge 1 commit into
NousResearch:mainfrom
loulin:fix/api-server-tool-completion-sse
Closed

fix(api-server): emit chat tool completion progress#16591
loulin wants to merge 1 commit into
NousResearch:mainfrom
loulin:fix/api-server-tool-completion-sse

Conversation

@loulin

@loulin loulin commented Apr 27, 2026

Copy link
Copy Markdown

What does this PR do?

Emit structured hermes.tool.progress completion events from the OpenAI-compatible /v1/chat/completions streaming 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_callback and tool_complete_callback into the chat stream and includes a stable toolCallId on both running and completed events.

Related Issue

Fixes #16588

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • gateway/platforms/api_server.py: adds a shared queue helper for chat-completion tool progress events and wires tool_start_callback / tool_complete_callback into _run_agent.
  • tests/gateway/test_api_server.py: updates streaming tool-progress tests to assert toolCallId and running status, and adds coverage for completed progress with output before the final assistant content.

How to Test

  1. Run scripts/run_tests.sh tests/gateway/test_api_server.py -k 'tool_progress or tool_completed_progress'.
  2. Run scripts/run_tests.sh tests/gateway/test_api_server.py.
  3. Run 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

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 15, Python 3.12.10

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — no platform-specific code added
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

For New Skills

N/A

Screenshots / Logs

Not applicable. The behavior is covered by the streaming SSE assertions in tests/gateway/test_api_server.py.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery labels Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: chat completions SSE does not emit tool completion progress

2 participants