Skip to content

fix: preserve tool-turn context in chat/completions (#14270)#3

Merged
aideautomation merged 3 commits into
mainfrom
fix/openwebui-tool-memory-p1
Apr 23, 2026
Merged

fix: preserve tool-turn context in chat/completions (#14270)#3
aideautomation merged 3 commits into
mainfrom
fix/openwebui-tool-memory-p1

Conversation

@aideautomation

Copy link
Copy Markdown
Owner

결론

Open WebUI 계열 클라이언트에서 도구 호출 맥락이 다음 턴에 소실되는 문제(NousResearch#14270)를 chat/completions 경로에서 재현 테스트 후 수정했습니다.

원인

  • /v1/chat/completions 파서가 user/assistant만 conversation_history에 포함하고 tool role은 버렸습니다.
  • 또한 마지막 메시지를 무조건 user_message로 간주해, 일부 클라이언트에서 trailing tool/assistant 턴이 섞일 때 입력 추출이 불안정했습니다.
  • assistant tool-call 턴이 content: "" + tool_calls 형태로 전달되면, 이전 턴에 도구를 불렀다는 힌트가 완전히 사라졌습니다.

수정 내용

  1. tool role 메시지를 conversation_history에 포함
  2. assistant 턴이 empty content + tool_calls인 경우, 툴 이름 기반 marker를 history에 보존
    • 예: [assistant issued tool calls: read_file]
  3. user_message 추출을 "마지막 메시지"가 아닌 "마지막 유효 user 턴" 기준으로 변경

테스트

  • test_tool_messages_and_assistant_tool_calls_are_preserved
  • test_last_user_message_selected_when_trailing_tool_message_exists
  • 기존 test_conversation_history_passed 회귀 포함

실행:

  • scripts/run_tests.sh tests/gateway/test_api_server.py::TestChatCompletionsEndpoint

결과:

  • 17 passed

연계 이슈

@aideautomation aideautomation merged commit 00acd86 into main Apr 23, 2026
@aideautomation aideautomation deleted the fix/openwebui-tool-memory-p1 branch April 23, 2026 04:07
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.

[Bug]: Open WebUI doesn't remember tool calls, causing erratic assistant behaviour

1 participant