defmodule Eai.Tool.ExportContext do @behaviour Eai.Tool @impl true def schema do %{type: "function", function: %{ name: "export_context", description: "Export the current conversation history to a gzip file (same format as Record). Returns the file path.", parameters: %{type: "object", properties: %{file_path: %{type: "string", description: "Absolute path for the .gz file to save to."}}, required: ["file_path"] } }} end @impl true def execute(args, _pty_session_id, chat_session_id) do file_path = args["file_path"] case Eai.Naming.chat().export_history(file_path, chat_session_id) do {:ok, path} -> Jason.encode!(%{ok: true, file: path}) {:error, reason} -> Jason.encode!(%{ok: false, error: reason}) end end end