mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-07-09 12:07:18 +00:00
fix(copilot): guard request_flags against a non-dict last message (#5274)
request_flags derives (agent, vision) and does last.get("role") after only
a truthy check. A client can send a bare-string message element
("messages": ["hi"]), and the vision loop right below already guards each
element with isinstance — so the .get() on a non-dict last element is an
oversight that raises AttributeError on every Copilot-proxied request with
such a body.
Use isinstance(last, dict) to match the loop's own guard.
Fixes #5273
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+4
-1
@@ -230,7 +230,10 @@ def request_flags(messages) -> tuple:
|
||||
"""
|
||||
msgs = messages or []
|
||||
last = msgs[-1] if msgs else None
|
||||
agent = bool(last) and last.get("role") != "user"
|
||||
# A message element can be a non-dict (clients send `"messages": ["hi"]`);
|
||||
# the vision loop below already guards each element with isinstance, so do
|
||||
# the same here rather than call .get() on a bare string.
|
||||
agent = isinstance(last, dict) and last.get("role") != "user"
|
||||
vision = False
|
||||
for m in msgs:
|
||||
content = m.get("content") if isinstance(m, dict) else None
|
||||
|
||||
Reference in New Issue
Block a user