Skip to content

Commit 6ca500d

Browse files
committed
Cut over to agent-core for OpenAI Agent SDK wrapper
OpenAIAgent and supporting helpers moved to the new agent-core package. This bot now imports them from there instead of carrying its own copy. - pyproject.toml: add agent-core as a git dependency, enable hatchling allow-direct-references so the build accepts it - bot/agents.py: deleted (moved to agent-core) - bot/telegram.py: import OpenAIAgent from agent_core - bot/config.py: re-export env_flag from agent_core.env so existing callers (app.py, tests) keep working - app.py: import OpenAIAgent from agent_core - tests/test_agents.py: deleted; the same coverage now lives in agent-core's own test suite Net diff: -800 lines.
1 parent cd41a2f commit 6ca500d

7 files changed

Lines changed: 396 additions & 1196 deletions

File tree

app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import logging
77
import sys
88

9+
from agent_core import OpenAIAgent
910
from agents import enable_verbose_stdout_logging
1011

11-
from bot.agents import OpenAIAgent
1212
from bot.auth import add_group
1313
from bot.auth import allow_user
1414
from bot.auth import confirm_pairing

bot/agents.py

Lines changed: 0 additions & 292 deletions
This file was deleted.

bot/config.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,13 @@
33
import os
44
from typing import Any
55

6+
from agent_core.env import env_flag
67
from dotenv import find_dotenv
78
from dotenv import load_dotenv
89

9-
logger = logging.getLogger(__name__)
10-
11-
_FALSY_ENV_VALUES = frozenset({"", "0", "false", "no", "off"})
12-
10+
__all__ = ["Configuration", "env_flag"]
1311

14-
def env_flag(name: str) -> bool:
15-
"""Return True if env var ``name`` is set to a truthy value.
16-
17-
Common falsy spellings (empty, "0", "false", "no", "off") are treated as
18-
disabled so that ``FOO=0`` behaves as users intuitively expect rather than
19-
as Python's default "non-empty string is truthy" rule.
20-
"""
21-
raw = os.getenv(name)
22-
if raw is None:
23-
return False
24-
return raw.strip().lower() not in _FALSY_ENV_VALUES
12+
logger = logging.getLogger(__name__)
2513

2614

2715
class Configuration:

bot/telegram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
from collections import deque
66

7+
from agent_core import OpenAIAgent
78
from telegram import Message
89
from telegram import Update
910
from telegram.constants import ChatAction
@@ -14,7 +15,6 @@
1415
from telegram.ext import MessageHandler
1516
from telegram.ext import filters
1617

17-
from .agents import OpenAIAgent
1818
from .auth import create_pairing_code
1919
from .auth import get_dm_policy
2020
from .auth import get_group_config

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description = "Add your description here"
55
readme = "README.md"
66
requires-python = ">=3.14"
77
dependencies = [
8+
"agent-core @ git+https://github.com/John-Lin/agent-core.git",
89
"mistune-telegram>=0.5.0",
910
"openai-agents>=0.13.0",
1011
"python-dotenv>=1.1.0",
@@ -60,5 +61,8 @@ log_file_level = "INFO"
6061
log_format = "%(asctime)s %(levelname)s %(message)s"
6162
log_date_format = "%Y-%m-%d %H:%M:%S"
6263

64+
[tool.hatch.metadata]
65+
allow-direct-references = true
66+
6367
[tool.hatch.build.targets.wheel]
6468
packages = ["bot"]

0 commit comments

Comments
 (0)