Update src/txagent/txagent.py
Browse files- src/txagent/txagent.py +8 -5
src/txagent/txagent.py
CHANGED
@@ -827,7 +827,11 @@ Generate **one summarized sentence** about "function calls' responses" with nece
|
|
827 |
if special_tool_call == 'Finish':
|
828 |
next_round = False
|
829 |
conversation.extend(function_call_messages)
|
830 |
-
|
|
|
|
|
|
|
|
|
831 |
elif special_tool_call == 'RequireClarification' or special_tool_call == 'DirectResponse':
|
832 |
history.append(
|
833 |
ChatMessage(role="assistant", content=history[-1].content))
|
@@ -872,7 +876,7 @@ Generate **one summarized sentence** about "function calls' responses" with nece
|
|
872 |
if '[FinalAnswer]' in last_thought:
|
873 |
_, final_answer = last_thought.split('[FinalAnswer]', 1)
|
874 |
history.append(
|
875 |
-
ChatMessage(role="assistant", content=
|
876 |
)
|
877 |
yield history
|
878 |
return
|
@@ -893,7 +897,7 @@ Generate **one summarized sentence** about "function calls' responses" with nece
|
|
893 |
if '[FinalAnswer]' in last_thought:
|
894 |
_, final_answer = last_thought.split('[FinalAnswer]', 1)
|
895 |
history.append(
|
896 |
-
ChatMessage(role="assistant", content=
|
897 |
)
|
898 |
yield history
|
899 |
else:
|
@@ -916,9 +920,8 @@ Generate **one summarized sentence** about "function calls' responses" with nece
|
|
916 |
else:
|
917 |
final_answer = last_thought
|
918 |
history.append(
|
919 |
-
ChatMessage(role="assistant", content=
|
920 |
)
|
921 |
yield history
|
922 |
else:
|
923 |
return None
|
924 |
-
|
|
|
827 |
if special_tool_call == 'Finish':
|
828 |
next_round = False
|
829 |
conversation.extend(function_call_messages)
|
830 |
+
if function_call_messages and len(function_call_messages) > 0:
|
831 |
+
return function_call_messages[0]['content']
|
832 |
+
else:
|
833 |
+
print("[⚠️ Warning] function_call_messages is empty")
|
834 |
+
return "An internal reasoning error occurred — no tool response was returned."
|
835 |
elif special_tool_call == 'RequireClarification' or special_tool_call == 'DirectResponse':
|
836 |
history.append(
|
837 |
ChatMessage(role="assistant", content=history[-1].content))
|
|
|
876 |
if '[FinalAnswer]' in last_thought:
|
877 |
_, final_answer = last_thought.split('[FinalAnswer]', 1)
|
878 |
history.append(
|
879 |
+
ChatMessage(role="assistant", content=final_answer.strip())
|
880 |
)
|
881 |
yield history
|
882 |
return
|
|
|
897 |
if '[FinalAnswer]' in last_thought:
|
898 |
_, final_answer = last_thought.split('[FinalAnswer]', 1)
|
899 |
history.append(
|
900 |
+
ChatMessage(role="assistant", content=final_answer.strip())
|
901 |
)
|
902 |
yield history
|
903 |
else:
|
|
|
920 |
else:
|
921 |
final_answer = last_thought
|
922 |
history.append(
|
923 |
+
ChatMessage(role="assistant", content=final_answer.strip())
|
924 |
)
|
925 |
yield history
|
926 |
else:
|
927 |
return None
|
|