fix(async-context-compression): parse summary responses safely#73
Conversation
| if isinstance(message, dict): | ||
| text = collect_text(message.get("content")) | ||
| if text.strip(): | ||
| return text.strip() | ||
|
|
||
| text = collect_text(first_choice.get("text")) | ||
| if text.strip(): | ||
| return text.strip() |
There was a problem hiding this comment.
在处理 choices 列表时,目前的逻辑对 message 和 first_choice 的取值较为固定(仅尝试了 content 或 text 键)。为了更充分地利用 collect_text 函数提供的多键名遍历和递归提取能力,建议直接对 message 和 first_choice 对象调用 collect_text。这样可以自动兼容那些将摘要文本放在 output_text 或其他常用字段中的非标准 Provider 响应,使解析逻辑更加稳健。
| if isinstance(message, dict): | |
| text = collect_text(message.get("content")) | |
| if text.strip(): | |
| return text.strip() | |
| text = collect_text(first_choice.get("text")) | |
| if text.strip(): | |
| return text.strip() | |
| if isinstance(message, dict): | |
| text = collect_text(message) | |
| if text.strip(): | |
| return text.strip() | |
| text = collect_text(first_choice) | |
| if text.strip(): | |
| return text.strip() |
|
I still think the risk is relatively high here. This code path has quite a few moving parts, and there are multiple places where the behavior can diverge depending on the provider response shape, so I would prefer to be cautious before merging. Could you please provide real runtime evidence from actual OpenWebUI testing? Specifically, it would help to see:
If the runtime logs look clean in both scenarios, I can reconsider merging. |
|
Hi. You can check |
|
|
@NexZhu I pushed a follow-up commit on top of this PR: Reason for the change:
I also synced the related v1.6.3 release-prep documentation files so the release surface stays consistent. Could you please test this updated branch in your environment? It would be especially helpful to confirm:
The targeted regression tests pass on my side, but since your environment is the one that originally exposed this path, I would still like a real runtime check from you before we finalize it. |
- accept responses-style summary payloads without a choices array - ignore reasoning-only output and surface compact empty-summary diagnostics - sync README, docs, indexes, and release notes for v1.6.4
481ef4b to
e064c02
Compare
|
I rebased this PR on top of the merged v1.6.3 changes from #76 and force-updated the branch as v1.6.4, because the plugin-version check now requires a new version for the next sequential PR to main.\n\nWhat changed in this update:\n- Kept the response-shape parsing fix so _call_summary_llm() can accept output-only / Responses-style payloads instead of failing on a stale choices-only gate.\n- Preserved the current SUMMARY_FAIL_MODE behavior from main, so this PR only adds the remaining response-parsing compatibility layer on top of the shipped 1.6.3 behavior.\n- Refreshed the tests and release/documentation surfaces for v1.6.4.\n\nCould you please re-test on the updated branch? If possible, please include:\n1. a normal successful run\n2. a provider response that does not use choices (Responses-style output payload)\n3. browser-console logs or screenshots if anything still looks off |
|
@Fu-Jie I've re-tested your version in my environment, compression worked as expected. |
…tions Merge PR #77 from mhajder/openwebui-extensions - Add complete pl-PL translation set to TRANSLATIONS dict - Update GEMINI.md to list pl-PL in supported languages - Add contributors NexZhu (code, PR #73) and mhajder (translation, PR #77) to README.md, README_CN.md, and .all-contributorsrc (badge: 8 → 10) Co-authored-by: mhajder <mhajder@users.noreply.github.com>
|
Thank you for the contribution, @NexZhu! 🎉 This PR was merged via a rebase into You've been added to the Contributors section of the project. Thanks for making the plugin more robust! 🚀 |
Summary
Fixes Async Context Compression summary extraction when the summary provider returns text in non-standard response shapes.
What Changed
choices[].message.contentoutput_textoutputmessage itemsreasoning_content,thinking, and reasoning output items, so private reasoning isnot saved as chat memory.
1.6.3.Verification
PYTHONPYCACHEPREFIX=/private/tmp/pycache-openwebui /usr/bin/python3 -m unittest plugins.filters.async-context- compression.test_async_context_compression.TestAsyncContextCompression.test_extract_summary_text_supports_alternate_response_shapes plugins.filters.async-context- compression.test_async_context_compression.TestAsyncContextCompression.test_call_summary_llm_rejects_empty_message_contentPYTHONPYCACHEPREFIX=/private/tmp/pycache-openwebui /usr/bin/python3 -m py_compile plugins/filters/async-context-compression/ async_context_compression.py plugins/filters/async-context-compression/test_async_context_compression.py