修复错误返回时SDK对象和dict冲突

This commit is contained in:
Panda-eyes123
2026-06-14 21:54:22 +08:00
parent 20e7cbb72c
commit 4e594bb84a
8 changed files with 16 additions and 2 deletions

View File

@@ -373,4 +373,6 @@ if __name__ == "__main__":
for block in history[-1]["content"]: for block in history[-1]["content"]:
if getattr(block, "type", None) == "text": if getattr(block, "type", None) == "text":
print(block.text) print(block.text)
elif isinstance(block, dict) and block.get("type") == "text":
print(block.get("text", ""))
print() print()

View File

@@ -475,4 +475,6 @@ if __name__ == "__main__":
for block in history[-1]["content"]: for block in history[-1]["content"]:
if getattr(block, "type", None) == "text": if getattr(block, "type", None) == "text":
print(block.text) print(block.text)
elif isinstance(block, dict) and block.get("type") == "text":
print(block.get("text", ""))
print() print()

View File

@@ -916,6 +916,8 @@ if __name__ == "__main__":
for block in history[-1]["content"]: for block in history[-1]["content"]:
if getattr(block, "type", None) == "text": if getattr(block, "type", None) == "text":
print(block.text) print(block.text)
elif isinstance(block, dict) and block.get("type") == "text":
print(block.get("text", ""))
# Check inbox for teammate results → inject into history # Check inbox for teammate results → inject into history
inbox = BUS.read_inbox("lead") inbox = BUS.read_inbox("lead")

View File

@@ -868,6 +868,8 @@ if __name__ == "__main__":
for block in history[-1]["content"]: for block in history[-1]["content"]:
if getattr(block, "type", None) == "text": if getattr(block, "type", None) == "text":
print(block.text) print(block.text)
elif isinstance(block, dict) and block.get("type") == "text":
print(block.get("text", ""))
# Check inbox → route protocol + inject into history # Check inbox → route protocol + inject into history
inbox_msgs = consume_lead_inbox(route_protocol=True) inbox_msgs = consume_lead_inbox(route_protocol=True)

View File

@@ -800,6 +800,8 @@ if __name__ == "__main__":
for block in history[-1]["content"]: for block in history[-1]["content"]:
if getattr(block, "type", None) == "text": if getattr(block, "type", None) == "text":
print(block.text) print(block.text)
elif isinstance(block, dict) and block.get("type") == "text":
print(block.get("text", ""))
# Consume lead inbox: route protocol + inject into history # Consume lead inbox: route protocol + inject into history
inbox = consume_lead_inbox(route_protocol=True) inbox = consume_lead_inbox(route_protocol=True)

View File

@@ -984,6 +984,8 @@ if __name__ == "__main__":
for block in history[-1]["content"]: for block in history[-1]["content"]:
if getattr(block, "type", None) == "text": if getattr(block, "type", None) == "text":
print(block.text) print(block.text)
elif isinstance(block, dict) and block.get("type") == "text":
print(block.get("text", ""))
# Consume lead inbox: route protocol + inject into history # Consume lead inbox: route protocol + inject into history
inbox = consume_lead_inbox(route_protocol=True) inbox = consume_lead_inbox(route_protocol=True)

View File

@@ -1013,6 +1013,8 @@ if __name__ == "__main__":
for block in history[-1]["content"]: for block in history[-1]["content"]:
if getattr(block, "type", None) == "text": if getattr(block, "type", None) == "text":
print(block.text) print(block.text)
elif isinstance(block, dict) and block.get("type") == "text":
print(block.get("text", ""))
inbox = consume_lead_inbox(route_protocol=True) inbox = consume_lead_inbox(route_protocol=True)
if inbox: if inbox:

View File

@@ -2063,8 +2063,8 @@ def print_turn_assistants(messages: list, turn_start: int):
if msg.get("role") != "assistant": if msg.get("role") != "assistant":
continue continue
for block in msg.get("content", []): for block in msg.get("content", []):
if getattr(block, "type", None) == "text": if block_type(block) == "text":
terminal_print(block.text) terminal_print(block["text"] if isinstance(block, dict) else block.text)
def cron_autorun_loop(history: list, context: dict): def cron_autorun_loop(history: list, context: dict):