feat(agent-runtime): 实现运行审计与状态服务
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""OpenAI Agents SDK 与本地运行模型之间的稳定适配边界。"""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Protocol
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class AgentExecutionRequest:
|
||||
"""不包含 API Key、Cookie 等秘密的运行请求。"""
|
||||
|
||||
agent_run_id: str
|
||||
user_id: int
|
||||
input_summary: dict = field(default_factory=dict)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class AgentExecutionResult:
|
||||
"""Gateway 返回的脱敏运行结果。"""
|
||||
|
||||
succeeded: bool
|
||||
output_summary: dict = field(default_factory=dict)
|
||||
error_code: str = ""
|
||||
error_summary: str = ""
|
||||
|
||||
|
||||
class AgentRunnerGateway(Protocol):
|
||||
"""第二阶段真实 SDK Gateway 必须实现的最小协议。"""
|
||||
|
||||
def run(self, request: AgentExecutionRequest) -> AgentExecutionResult: ...
|
||||
|
||||
|
||||
class StubAgentRunnerGateway:
|
||||
"""测试使用的确定性替身,不发起任何外部或付费调用。"""
|
||||
|
||||
def __init__(self, result: AgentExecutionResult):
|
||||
self.result = result
|
||||
|
||||
def run(self, request: AgentExecutionRequest) -> AgentExecutionResult:
|
||||
return self.result
|
||||
Reference in New Issue
Block a user