Skip to content

Commit c9b87ac

Browse files
committed
revise message parsing
1 parent 63cc682 commit c9b87ac

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

ajet/context_tracker/multiagent_tracking.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def extract_text_content_from_content_dict(self, msg):
8282
# },
8383
# ],
8484
# }
85-
# or tool_result format:
85+
# or tool_result format?? not observed yet:
8686
# msg = {
8787
# "role": "tool",
8888
# "content": [
@@ -97,31 +97,27 @@ def extract_text_content_from_content_dict(self, msg):
9797

9898
str_content = ""
9999
for item in msg["content"]:
100-
assert isinstance(item, dict), f"Unsupported non-dict item in message content: {item}. Full message: {msg}"
101-
100+
# item = {
101+
# "type": "text",
102+
# "text": "some text"
103+
# },
102104
item_type = item.get("type", "")
105+
assert not item_type == "tool_use", f"never observed such protocal yet"
106+
assert not item_type == "tool_result", f"never observed such protocal yet"
103107

104-
# Handle text content block
105-
if "text" in item:
106-
if isinstance(item["text"], str):
107-
str_content += item["text"]
108-
# Handle tool_result content block (AgentScope format)
109-
elif item_type == "tool_result" and "output" in item:
110-
output = item["output"]
111-
if isinstance(output, str):
112-
str_content += output
113-
else:
114-
str_content += str(output)
115-
# Handle tool_use content block (for completeness)
116-
elif item_type == "tool_use":
117-
# tool_use blocks are handled via tool_calls field, skip content extraction
118-
continue
119-
else:
108+
assert isinstance(item, dict), f"Unsupported non-dict item in message content: {item}. Full message: {msg}"
109+
110+
if ("text" not in item):
120111
logger.warning(
121-
f"Non-text content in message content detected: {item}. Ignoring this item."
112+
f"Non-text content in message content detected: {item}. Ignoring."
122113
)
123-
# Continue processing other items instead of skipping the entire message
124-
continue
114+
should_skip_message = True
115+
return str_content, should_skip_message
116+
117+
if isinstance(item["text"], str):
118+
str_content += str(item["text"])
119+
else:
120+
str_content = ""
125121

126122
should_skip_message = False
127123
return str_content, should_skip_message

ajet/launcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def parse_args():
9999
default=False,
100100
help="Kill system processes (ray + vllm + python) that may block the current experiment",
101101
)
102-
parser.add_argument("--prefix", type=str, default="", required=False, help="Prefix for service names")
102+
parser.add_argument("--prefix", type=str, default="", required=False, help="Prefix for deepfinance service names")
103103
return parser.parse_args()
104104

105105

0 commit comments

Comments
 (0)