Ali2206 commited on
Commit
2e38b95
·
verified ·
1 Parent(s): 882450b

Update src/txagent/txagent.py

Browse files
Files changed (1) hide show
  1. src/txagent/txagent.py +9 -4
src/txagent/txagent.py CHANGED
@@ -428,7 +428,10 @@ class TxAgent:
428
  if isinstance(function_call_messages[0]['content'], types.GeneratorType):
429
  function_call_messages[0]['content'] = next(
430
  function_call_messages[0]['content'])
431
- return function_call_messages[0]['content'].split('[FinalAnswer]')[-1]
 
 
 
432
 
433
  if (self.enable_summary or token_overflow) and not call_agent:
434
  if token_overflow:
@@ -462,9 +465,11 @@ class TxAgent:
462
  max_new_tokens=max_new_tokens, max_token=max_token,
463
  check_token_status=True)
464
  if last_outputs_str is None:
465
- next_round = False
466
- print(
467
- "The number of tokens exceeds the maximum limit.")
 
 
468
  else:
469
  last_outputs.append(last_outputs_str)
470
  if max_round == current_round:
 
428
  if isinstance(function_call_messages[0]['content'], types.GeneratorType):
429
  function_call_messages[0]['content'] = next(
430
  function_call_messages[0]['content'])
431
+ content = function_call_messages[0]['content']
432
+ if content is None:
433
+ return "❌ No content returned after Finish tool call."
434
+ return content.split('[FinalAnswer]')[-1]
435
 
436
  if (self.enable_summary or token_overflow) and not call_agent:
437
  if token_overflow:
 
465
  max_new_tokens=max_new_tokens, max_token=max_token,
466
  check_token_status=True)
467
  if last_outputs_str is None:
468
+ print("The number of tokens exceeds the maximum limit.")
469
+ if self.force_finish:
470
+ return self.get_answer_based_on_unfinished_reasoning(conversation, temperature, max_new_tokens, max_token)
471
+ else:
472
+ return "❌ Token limit exceeded — no further steps possible."
473
  else:
474
  last_outputs.append(last_outputs_str)
475
  if max_round == current_round: