diff options
| author | Guillermo Serrahima <dev@vylion.com> | 2026-06-26 14:39:23 +0200 |
|---|---|---|
| committer | Guillermo Serrahima <dev@vylion.com> | 2026-06-26 14:39:23 +0200 |
| commit | 963f59569437fe43a49ce36a003a143fa2f767c8 (patch) | |
| tree | 968b0dad13193536770ae1e6b580b27e22f9366b /agent/orchestrator/models/base.py | |
| parent | 741a04c2abcbd77451c0933a19d91fddb9982882 (diff) | |
| download | senia-963f59569437fe43a49ce36a003a143fa2f767c8.tar.xz senia-963f59569437fe43a49ce36a003a143fa2f767c8.zip | |
created custom agent loop
Diffstat (limited to 'agent/orchestrator/models/base.py')
| -rw-r--r-- | agent/orchestrator/models/base.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/agent/orchestrator/models/base.py b/agent/orchestrator/models/base.py new file mode 100644 index 0000000..4ca1988 --- /dev/null +++ b/agent/orchestrator/models/base.py @@ -0,0 +1,44 @@ +"""Backend-agnostic model interface. + +Concrete backends (Claude Code, Ollama, Anthropic API direct, OpenCode, etc.) +implement `ModelBackend.call`. The orchestration code only ever talks to this +interface, never to a specific backend. + +Persona is NOT carried in ModelRequest; that's a backend-level configuration +concern (some backends autodiscover persona from a workspace, others need to +be told). What flows through here is per-turn DYNAMIC context only. +""" + +from abc import ABC, abstractmethod +from dataclasses import dataclass, field +from typing import Literal + + +Role = Literal["system", "user", "assistant", "tool"] + + +@dataclass +class Message: + role: Role + content: str + + +@dataclass +class ModelRequest: + """Everything a backend needs to produce one response.""" + messages: list[Message] + turn_context: str | None = None + extras: dict = field(default_factory=dict) + + +@dataclass +class ModelResponse: + """What a backend returns. Kept narrow now, extended later.""" + content: str + extras: dict = field(default_factory=dict) + + +class ModelBackend(ABC): + @abstractmethod + def call(self, request: ModelRequest) -> ModelResponse: + ... |
