Skip to content

Commit 9186bad

Browse files
fix: add logfire.force_flush before Modal function returns
1 parent c14c83d commit 9186bad

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/policyengine_api/agent_sandbox.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ def run_agent(
529529
configure_logfire(traceparent)
530530

531531
with logfire.span("run_agent", call_id=call_id, question=question[:200]):
532-
return _run_agent_impl(
532+
result = _run_agent_impl(
533533
question,
534534
api_base_url,
535535
call_id,
@@ -538,6 +538,10 @@ def run_agent(
538538
traceparent=traceparent,
539539
)
540540

541+
# Ensure logfire sends all spans before Modal container exits
542+
logfire.force_flush()
543+
return result
544+
541545

542546
if __name__ == "__main__":
543547
import sys

0 commit comments

Comments
 (0)