Skip to content

Recorder cannot save a session to a bare relative filename #8346

Open

Description

Bug

ChatCompletionClientRecorder.finalize() fails when session_file_path is a bare relative filename, such as session.json. os.path.dirname("session.json") is empty, so the unconditional os.makedirs("") raises FileNotFoundError, wrapped as ValueError. Using ./session.json works.

Reproduction

On current main, Windows and Python 3.11.14, with local editable autogen-core, autogen-agentchat and autogen-ext packages and the task-centric memory import dependency installed:

import asyncio
from autogen_core.models import UserMessage
from autogen_ext.models.replay import ReplayChatCompletionClient
from autogen_ext.experimental.task_centric_memory.utils.chat_completion_client_recorder import ChatCompletionClientRecorder

async def main():
    recorder = ChatCompletionClientRecorder(
        ReplayChatCompletionClient(["hello"]),
        mode="record",
        session_file_path="session.json",
    )
    await recorder.create([UserMessage(content="Hi", source="user")])
    recorder.finalize()

asyncio.run(main())

Actual: ValueError: Failed to write records to 'session.json': [WinError 3] The system cannot find the path specified: ''.

Expected: save the recorded interaction to the working directory and allow replaying it. No provider credentials or network inference is required.

I can submit a focused fix that creates a parent directory only when the filename includes one, with record/replay regressions for bare, explicit-relative, nested and absolute paths. #7797 changes text encoding in this module but leaves the directory creation unchanged, so this is a separate failure.

Investigated with Codex assistance; reproduction ran against the real recorder and replay client.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions