Initial project structure
Scaffold all modules, route stubs, data models, and config. No logic implemented yet — all core methods raise NotImplementedError. Establishes the full directory layout matching the architecture in CLAUDE.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
42
fellowship/core/context.py
Normal file
42
fellowship/core/context.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""
|
||||
Context manager — assembles the conversation history for a bot's prompt.
|
||||
Ensures bots only see messages, never foreign system prompts.
|
||||
Handles context summarization when enabled.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fellowship.core.session import Session, BotConfig
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ContextManager:
|
||||
def __init__(self, session: "Session") -> None:
|
||||
self.session = session
|
||||
|
||||
def build_context(self, bot: "BotConfig") -> list[dict]:
|
||||
"""
|
||||
Return the conversation history formatted as LLM messages for the given bot.
|
||||
Uses shared_context or scoped_context based on session options.
|
||||
Skips any slots with content=None (reserved but not yet filled).
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def estimate_tokens(self, messages: list[dict]) -> int:
|
||||
"""
|
||||
Estimate total token count for a list of messages.
|
||||
Used to check against max_context_tokens.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
async def summarize(self) -> None:
|
||||
"""
|
||||
Summarize the older portion of history to reduce context size.
|
||||
Retains a recent tail of messages intact.
|
||||
Stores the summary in session state; future context builds use summary + tail.
|
||||
Full history list is preserved unchanged.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
Reference in New Issue
Block a user