Hi everyone! It seems that LLM logging (by setting...
# proj-agent
b
Hi everyone! It seems that LLM logging (by setting log_completions=True in LLM class) does not save any logs on user's machine when running this example. If I understand agent-sdk correctly, when running remotely (via Docker and/or remote runtime), the user's machine just talks to a server in the sandbox where all of agent-sdk's code is run and the LLM calls are made and logged. If this is true, then the log_dir in Telemetry will point to a path in the remote container, and not on user's machine which is probably why this happens? When using the default log_completions_folder, I see a log entry from Docker container (I set DEBUG=1) saying:
Copy code
[DOCKER] openhands/sdk/llm/utils/telemetry.py:301: UserWarning: Telemetry logging failed: log_dir does not exist: logs/completions
When I set log_completions_folder to a
/tmp/logs/completions
and make this directory in remote sandbox using
workspace.execute_command("mkdir -p /tmp/logs/completions")
, I see that the JSON files are being logged inside the docker container at the above location, but they are all empty, and the logs now say:
Copy code
[DOCKER] openhands/sdk/llm/utils/telemetry.py:301: UserWarning: Telemetry logging failed: Circular reference detected
Is there some other way of logging the exact LLM prompts used at each step of the agent?
l
Hey @busy-branch-28834, this sounds like a bug, maybe you could open an issue on the agent SDK repo?
b
Ok sir. I will create an issue for this
As a temporary workaround for this problem, I have implemented a small fix that registers a callback for each event in agent-sdk where we save the exact LLM prompts for each action-observation pair for SWE-Bench Eval: https://github.com/adityasoni9998/benchmarks/pull/1/files. We can atleast use these LLM logs to design intermediate rewards I guess?
l
@rapid-london-15934 was interested in this too
@busy-branch-28834 I see the issue was closed but I donโ€™t think itโ€™s actually fully solved, right?
c
No, it wasn't, it got closed automatically on a PR fixing a part
I reopened it
๐Ÿ‘ 1
b
Hi Graham sir and Engel! No this issue is not fixed. Basically that PR just ensures that the LLM messages can be serialized to a JSON string without errors. We still need to ensure that the LLM logs directory is mounted on user's machine. Currently we just log inside remote workspace.
๐Ÿ‘ 1
l
(although maybe it would need to be extended to work with directories)
Thanks!
b
I was initially thinking of using
mount_dir
in docker workspace, but realized that this probably won't work for remote runtime API. A simple (and somewhat hacky) solution to use
file_download
as-is would be to create a
directory_download
function that zips the folder on the remote machine, downloads the file to user's machine, and unzips it.
Acutally, OpenHands is also using the same zip file method it seems: see here and here.
c
nod For the full workspace, or uploading a file from the user
Given that these are LLM prompts and responses, I was thinking it would be nice if they were sent... like events, at every step ๐Ÿ˜Š But I guess that might be overkill
l
I think the easy thing could work for @busy-branch-28834 and @rapid-london-15934 now but having them written locally every time could also be nice!
๐Ÿ‘ 1