Skip to content

Conversation

@SmartManoj
Copy link
Contributor

Problem

When log_completions=True is set, logging silently fails if the directory doesn't exist:

  • Users see a UserWarning at the end of the output.
  • All logs for the entire session are lost
llm = LLM(model="gpt-4", log_completions=True)
# UserWarning: Telemetry logging failed: log_dir does not exist: logs/completions

Solution

Auto-create the log directory.

Why This Approach?

  1. Better UX: Users expect log_completions=True to work out of the box
  2. Fail fast: Permission errors still raise immediately with clear messages
  3. Standard practice: SDKs routinely create directories (cache dirs, config dirs, etc.)
  4. No data loss: Previous behavior silently dropped all logs

Replaces the previous check for log directory existence with automatic creation using os.makedirs. This allows telemetry logging to proceed even if the log directory does not already exist.
@blacksmith-sh
Copy link
Contributor

blacksmith-sh bot commented Nov 10, 2025

[Automatic Post]: I have assigned @CLFutureX as a reviewer based on git blame information. Thanks in advance for the help!

Copy link
Collaborator

@xingyaoww xingyaoww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@xingyaoww xingyaoww merged commit f3c0c19 into OpenHands:main Nov 10, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants