refactor: enhance API interaction and message handling in AIAgent

- Introduced new methods in run_agent.py for building API keyword arguments and normalizing assistant messages from API responses.
- Added functionality for compressing conversation context and managing session state in SQLite.
- Improved tool call execution handling, including enhanced logging and error management.
- Updated path handling in multiple platform files to utilize pathlib for better compatibility and readability.
This commit is contained in:
teknium1 2026-02-21 04:17:27 -08:00
parent 7ee7221af1
commit ecb430effe
6 changed files with 351 additions and 401 deletions

View file

@ -17,7 +17,8 @@ from typing import Dict, List, Optional, Any, Callable, Awaitable, Tuple
from enum import Enum
import sys
sys.path.insert(0, str(__file__).rsplit("/", 3)[0])
from pathlib import Path as _Path
sys.path.insert(0, str(_Path(__file__).resolve().parents[2]))
from gateway.config import Platform, PlatformConfig
from gateway.session import SessionSource

View file

@ -27,7 +27,8 @@ except ImportError:
commands = None
import sys
sys.path.insert(0, str(__file__).rsplit("/", 3)[0])
from pathlib import Path as _Path
sys.path.insert(0, str(_Path(__file__).resolve().parents[2]))
from gateway.config import Platform, PlatformConfig
from gateway.platforms.base import (

View file

@ -24,7 +24,8 @@ except ImportError:
AsyncWebClient = Any
import sys
sys.path.insert(0, str(__file__).rsplit("/", 3)[0])
from pathlib import Path as _Path
sys.path.insert(0, str(_Path(__file__).resolve().parents[2]))
from gateway.config import Platform, PlatformConfig
from gateway.platforms.base import (

View file

@ -30,7 +30,8 @@ except ImportError:
ContextTypes = Any
import sys
sys.path.insert(0, str(__file__).rsplit("/", 3)[0])
from pathlib import Path as _Path
sys.path.insert(0, str(_Path(__file__).resolve().parents[2]))
from gateway.config import Platform, PlatformConfig
from gateway.platforms.base import (

View file

@ -25,7 +25,7 @@ from typing import Dict, List, Optional, Any
logger = logging.getLogger(__name__)
import sys
sys.path.insert(0, str(__file__).rsplit("/", 3)[0])
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
from gateway.config import Platform, PlatformConfig
from gateway.platforms.base import (