- harness/es.py: append-only event store + проекции (образец — кооп-портал) - harness/levels.py: уровни 1с/1м/1ч/1д, контекст ∝ масштабу - harness/scheduler.py: уровневые потоки, идемпотентные тики, absorbed-стабы - harness/isolated_runner.py + _llm_worker.py: LLM-тик в сабпроцессе (глобальный asyncio-рантайм Strands не переживает 2+ create_harness) - cli.py: init/task/tasks/status/events + requeue (написан самим минутным агентом) - 9router: отдельный ключ sk-simbiot, модель auto (glm-5.3 первым)
67 lines
1.6 KiB
Python
67 lines
1.6 KiB
Python
"""Agent Interface.
|
|
|
|
Defines the minimal interface that all agent types must implement.
|
|
"""
|
|
|
|
from collections.abc import AsyncIterator
|
|
from typing import Any, Protocol, runtime_checkable
|
|
|
|
from ..types.agent import AgentInput
|
|
from .agent_result import AgentResult
|
|
|
|
|
|
@runtime_checkable
|
|
class AgentBase(Protocol):
|
|
"""Protocol defining the interface for all agent types in Strands.
|
|
|
|
This protocol defines the minimal contract that all agent implementations
|
|
must satisfy.
|
|
"""
|
|
|
|
async def invoke_async(
|
|
self,
|
|
prompt: AgentInput = None,
|
|
**kwargs: Any,
|
|
) -> AgentResult:
|
|
"""Asynchronously invoke the agent with the given prompt.
|
|
|
|
Args:
|
|
prompt: Input to the agent.
|
|
**kwargs: Additional arguments.
|
|
|
|
Returns:
|
|
AgentResult containing the agent's response.
|
|
"""
|
|
...
|
|
|
|
def __call__(
|
|
self,
|
|
prompt: AgentInput = None,
|
|
**kwargs: Any,
|
|
) -> AgentResult:
|
|
"""Synchronously invoke the agent with the given prompt.
|
|
|
|
Args:
|
|
prompt: Input to the agent.
|
|
**kwargs: Additional arguments.
|
|
|
|
Returns:
|
|
AgentResult containing the agent's response.
|
|
"""
|
|
...
|
|
|
|
def stream_async(
|
|
self,
|
|
prompt: AgentInput = None,
|
|
**kwargs: Any,
|
|
) -> AsyncIterator[Any]:
|
|
"""Stream agent execution asynchronously.
|
|
|
|
Args:
|
|
prompt: Input to the agent.
|
|
**kwargs: Additional arguments.
|
|
|
|
Yields:
|
|
Events representing the streaming execution.
|
|
"""
|
|
...
|