Skip to content

The agent that grows with you

fix(agent): restore end_turn in run_conversation finally

fangliquanflq2e75aec512dd
diff --git a/run_agent.py b/run_agent.py
index 2f76c66572e..fe52149a7ec 100644
--- a/run_agent.py
+++ b/run_agent.py
@@ -7563,6 +7563,13 @@ class AIAgent:
finish_task_run(**task_context, error=exc)
raise
finally:
+ try:
+ if relay_turn is not None:
+ relay_runtime.SESSION_COORDINATOR.end_turn(
+ relay_turn,
+ outcome=relay_outcome,
+ )
+ finally:
try:
if relay_lease is not None:
relay_runtime.SESSION_COORDINATOR.release_conversation(
@@ -7581,9 +7588,6 @@ class AIAgent:
reset_accounting_context(acct_token)
if token is not None:
reset_conversation_context(token)
- reset_accounting_context(acct_token)
- if token is not None:
- reset_conversation_context(token)
def chat(self, message: str, stream_callback: Optional[callable] = None) -> str:
"""