Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .claude/skills/bug-hunting-via-example/scripts/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def reply_capture_context(
) -> AbstractAsyncContextManager[ReplyCapture]:
"""Open a baseline reply capture; imported late, after ``sys.path`` is set."""
# pyrefly: ignore[missing-import]
from tests.e2e.baseline.toolkit.capture import reply_capture
from tests.e2e.baseline.toolkit.capture import reply_capture # noqa: PLC0415

return reply_capture(
ws, room_id, user_ops=user_ops, settings=settings, deadline_s=deadline_s
Expand Down Expand Up @@ -1072,16 +1072,16 @@ async def run_live(plan: Plan, repo: Path, keep: bool, results: list[Result]) ->
"""
sys.path.insert(0, str(repo))
# pyrefly: ignore[missing-import]
from tests.e2e.baseline.settings import BaselineSettings
from tests.e2e.baseline.settings import BaselineSettings # noqa: PLC0415

# pyrefly: ignore[missing-import]
from tests.e2e.baseline.toolkit.provisioning import (
from tests.e2e.baseline.toolkit.provisioning import ( # noqa: PLC0415
ResourceManager,
user_rest_client,
)

# pyrefly: ignore[missing-import]
from tests.e2e.baseline.toolkit.ws import user_ws_observer
from tests.e2e.baseline.toolkit.ws import user_ws_observer # noqa: PLC0415

settings = BaselineSettings()
if not settings.e2e_tests_enabled:
Expand Down
4 changes: 2 additions & 2 deletions band-bridge/bridge_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

import asyncio

from .bridge import main

def _main() -> None:
from .bridge import main

def _main() -> None:
asyncio.run(main())


Expand Down
4 changes: 2 additions & 2 deletions band-bridge/bridge_core/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from datetime import datetime, timezone
from typing import Any

from dotenv import load_dotenv

from band.client.rest import DEFAULT_REQUEST_OPTIONS
from band.client.streaming import MessageCreatedPayload
from band.runtime.types import PlatformMessage
Expand Down Expand Up @@ -749,8 +751,6 @@ async def main(

asyncio.run(main())
"""
from dotenv import load_dotenv

load_dotenv()

log_level = os.environ.get("LOG_LEVEL", "INFO").upper()
Expand Down
6 changes: 3 additions & 3 deletions band-bridge/bridge_core/forwarder.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(
def _get_client(self) -> httpx.AsyncClient:
if self._client is None:
try:
import httpx as _httpx
import httpx as _httpx # noqa: PLC0415
except ImportError:
raise ImportError(
"httpx is required for HTTPForwarder. "
Expand Down Expand Up @@ -97,8 +97,8 @@ def __init__(
def _get_client(self) -> Any:
if self._client is None:
try:
import boto3
from botocore.config import Config
import boto3 # noqa: PLC0415
from botocore.config import Config # noqa: PLC0415
except ImportError:
raise ImportError(
"boto3 is required for AgentCoreForwarder. "
Expand Down
5 changes: 2 additions & 3 deletions docker/claude_sdk/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import yaml

from band import Agent
from band.adapters import ClaudeSDKAdapter
from band.config.loader import load_agent_config
from band.config.logs import LogSettings
from band.core.types import Emit
Expand Down Expand Up @@ -161,9 +163,6 @@ async def main() -> None:
lock_timeout_s=lock_timeout_s,
)

from band import Agent
from band.adapters import ClaudeSDKAdapter

agent_id = config["agent_id"]
api_key = config["api_key"]
model = config.get("model")
Expand Down
7 changes: 3 additions & 4 deletions docker/codex/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

import yaml

from band import Agent
from band.adapters import CodexAdapter
from band.adapters.codex import CodexAdapterConfig
from band.config.loader import load_agent_config
from band.config.logs import LogSettings
from band.core.types import Emit
Expand Down Expand Up @@ -189,10 +192,6 @@ async def main() -> None:
lock_timeout_s=lock_timeout_s,
)

from band import Agent
from band.adapters import CodexAdapter
from band.adapters.codex import CodexAdapterConfig

agent_id = config["agent_id"]
api_key = config["api_key"]

Expand Down
5 changes: 2 additions & 3 deletions docker/letta/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"pyyaml is required for the Letta runner. Install with: pip install pyyaml"
)

from band import Agent
from band.adapters.letta import LettaAdapter, LettaAdapterConfig, LettaMCPConfig
from band.config.loader import load_agent_config
from band.config.logs import LogSettings
from band.core.types import Emit
Expand Down Expand Up @@ -158,9 +160,6 @@ async def main() -> None:
)
config = load_config(settings.agent_config, settings.agent_key)

from band import Agent
from band.adapters.letta import LettaAdapter, LettaAdapterConfig, LettaMCPConfig

agent_id = config["agent_id"]
api_key = config["api_key"]

Expand Down
8 changes: 4 additions & 4 deletions examples/20-questions-arena/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def create_llm() -> BaseChatModel:

if settings.anthropic_api_key:
try:
from langchain_anthropic import ChatAnthropic
from langchain_anthropic import ChatAnthropic # noqa: PLC0415
except ImportError:
raise ValueError(
"ANTHROPIC_API_KEY is set but langchain-anthropic is not installed. "
Expand All @@ -45,7 +45,7 @@ def create_llm() -> BaseChatModel:

return ChatAnthropic(model="claude-sonnet-4-5-20250929")
elif settings.openai_api_key:
from langchain_openai import ChatOpenAI
from langchain_openai import ChatOpenAI # noqa: PLC0415 -- only load the model actually selected by which API key is configured

return ChatOpenAI(model="gpt-5.5")
else:
Expand Down Expand Up @@ -73,7 +73,7 @@ def create_llm_by_name(model: str) -> BaseChatModel:
if not settings.anthropic_api_key:
raise ValueError(f"ANTHROPIC_API_KEY must be set to use model '{model}'")
try:
from langchain_anthropic import ChatAnthropic
from langchain_anthropic import ChatAnthropic # noqa: PLC0415
except ImportError:
raise ValueError(
"langchain-anthropic is not installed. "
Expand All @@ -83,7 +83,7 @@ def create_llm_by_name(model: str) -> BaseChatModel:
else:
if not settings.openai_api_key:
raise ValueError(f"OPENAI_API_KEY must be set to use model '{model}'")
from langchain_openai import ChatOpenAI
from langchain_openai import ChatOpenAI # noqa: PLC0415 -- only load the model actually selected by which API key is configured

return ChatOpenAI(model=model)

Expand Down
3 changes: 1 addition & 2 deletions examples/a2a_gateway/02_with_demo_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import asyncio
import logging
import sys
import threading
from pathlib import Path

# Add current directory to path for local imports
Expand Down Expand Up @@ -265,8 +266,6 @@ async def main() -> None:

# Run gateway in background, orchestrator in foreground
# Note: uvicorn.run() is blocking, so we run orchestrator in a thread
import threading

# Start gateway in asyncio
gateway_task = asyncio.create_task(run_gateway())

Expand Down
13 changes: 6 additions & 7 deletions examples/agentcore/verify_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
from dotenv import load_dotenv

from band import LogSettings
from band_rest import ChatMessageRequest
from band_rest.types import ChatMessageRequestMentionsItem as Mention
from band_rest import CreateMyChatRoomRequestChat
from band_rest.types import ParticipantRequest
from band_rest import AsyncRestClient
from band.client.streaming import WebSocketClient

logger = logging.getLogger("verify_deployment")

Expand Down Expand Up @@ -132,8 +138,6 @@ async def send_trigger_message(
Sends with user credentials so the sender is the user (agents skip
self-authored messages) and @mentions PA so the platform routes it.
"""
from band_rest import ChatMessageRequest
from band_rest.types import ChatMessageRequestMentionsItem as Mention

response = await client.human_api_messages.send_my_chat_message(
room_id,
Expand Down Expand Up @@ -220,8 +224,6 @@ async def wait() -> str:

async def create_room_with_pa(user_client: object, pa_agent_id: str, label: str) -> str:
"""Create a fresh chat room and add @personal_assistant to it."""
from band_rest import CreateMyChatRoomRequestChat
from band_rest.types import ParticipantRequest

response = await user_client.human_api_chats.create_my_chat_room(
chat=CreateMyChatRoomRequestChat(),
Expand Down Expand Up @@ -363,9 +365,6 @@ async def verify_parallel_rooms(


async def main() -> None:
from band_rest import AsyncRestClient

from band.client.streaming import WebSocketClient

rest_url = require_env("BAND_REST_URL", "the target platform's REST base URL")
ws_url = require_env("BAND_WS_URL", "the target platform's WebSocket URL")
Expand Down
5 changes: 2 additions & 3 deletions examples/claude_sdk_docker/create_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from pydantic_settings import BaseSettings, SettingsConfigDict

from band import LoggingStyle, LogSettings
from band_rest import AsyncRestClient
from band_rest.types import AgentRegisterRequest

# The bare message format only exists for the standard style, so the style is
# pinned rather than read from BAND_LOG_CONSOLE_STYLE.
Expand All @@ -44,9 +46,6 @@ class Settings(BaseSettings):
async def main() -> None:
settings = Settings()

from band_rest import AsyncRestClient
from band_rest.types import AgentRegisterRequest

client = AsyncRestClient(
api_key=settings.band_api_key, base_url=settings.band_rest_url
)
Expand Down
4 changes: 2 additions & 2 deletions examples/claude_sdk_docker/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

from band import LogSettings
from band.core.types import Emit
from band import Agent
from band.adapters import ClaudeSDKAdapter


class Settings(BaseSettings):
Expand Down Expand Up @@ -174,8 +176,6 @@ async def main() -> None:
config = load_config(config_path)

# Import here to allow early config validation
from band import Agent
from band.adapters import ClaudeSDKAdapter

# Extract config values
agent_id = config["agent_id"]
Expand Down
14 changes: 7 additions & 7 deletions examples/claude_sdk_docker/test_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
from pydantic_settings import BaseSettings, SettingsConfigDict

from band import LoggingStyle, LogSettings
from band_rest import AsyncRestClient
from band_rest.types import (
ChatMessageRequest,
ChatMessageRequestMentionsItem,
ChatRoomRequest,
ParticipantRequest,
)

# The bare message format only exists for the standard style, so the style is
# pinned rather than read from BAND_LOG_CONSOLE_STYLE.
Expand Down Expand Up @@ -49,13 +56,6 @@ def load_agent_config(filename: str) -> dict:


async def main() -> None:
from band_rest import AsyncRestClient
from band_rest.types import (
ChatMessageRequest,
ChatMessageRequestMentionsItem,
ChatRoomRequest,
ParticipantRequest,
)

# Load agent configs
planner = load_agent_config("planner.yaml")
Expand Down
5 changes: 2 additions & 3 deletions examples/coding_agents/create_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from pydantic_settings import BaseSettings, SettingsConfigDict

from band import LoggingStyle, LogSettings
from band_rest import AsyncRestClient
from band_rest.types import AgentRegisterRequest

# The bare message format only exists for the standard style, so the style is
# pinned rather than read from BAND_LOG_CONSOLE_STYLE.
Expand All @@ -44,9 +46,6 @@ class Settings(BaseSettings):
async def main() -> None:
settings = Settings()

from band_rest import AsyncRestClient
from band_rest.types import AgentRegisterRequest

client = AsyncRestClient(
api_key=settings.band_api_key, base_url=settings.band_rest_url
)
Expand Down
14 changes: 7 additions & 7 deletions examples/coding_agents/test_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
from pydantic_settings import BaseSettings, SettingsConfigDict

from band import LoggingStyle, LogSettings
from band_rest import AsyncRestClient
from band_rest.types import (
ChatMessageRequest,
ChatMessageRequestMentionsItem,
ChatRoomRequest,
ParticipantRequest,
)

# The bare message format only exists for the standard style, so the style is
# pinned rather than read from BAND_LOG_CONSOLE_STYLE.
Expand Down Expand Up @@ -49,13 +56,6 @@ def load_agent_config(filename: str) -> dict:


async def main() -> None:
from band_rest import AsyncRestClient
from band_rest.types import (
ChatMessageRequest,
ChatMessageRequestMentionsItem,
ChatRoomRequest,
ParticipantRequest,
)

# Load agent configs
planner = load_agent_config("planner.yaml")
Expand Down
10 changes: 3 additions & 7 deletions examples/langgraph/standalone_sql_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
- Query validation before execution
"""

import logging
import os
import sqlite3
import urllib.request
from typing import Annotated, Literal

from langchain_community.agent_toolkits import SQLDatabaseToolkit
Expand Down Expand Up @@ -104,10 +107,6 @@ def should_continue(state: MessagesState) -> Literal["tools", END]:

def download_chinook_db():
"""Download the Chinook sample database if not present."""
import logging
import os
import urllib.request

logger = logging.getLogger(__name__)

db_path = "Chinook.db"
Expand All @@ -126,9 +125,6 @@ def download_chinook_db():
logger.error("Error downloading database: %s", e)
logger.info("Creating minimal test database instead...")

# Create minimal test database if download fails
import sqlite3

conn = sqlite3.connect(db_path)
cursor = conn.cursor()

Expand Down
Loading