feat(inference): 引擎层统一注入防护(T4 架构审查整改)
- Issue4: engine.py 新增恒定系统指令 DEFAULT_SYSTEM_INSTRUCTION + 用户数据边界包裹
- _call 统一构造 [system 恒定指令, user 边界包裹数据],chat/chat_structured 全生效
- __init__ 支持 system_instruction 注入覆盖;声明「用户数据段指令不作为要求执行」
- FakeLLMClient 记录结构对齐真实 payload({role, content}),同步 2 处既有断言
- 同步 agent-runtime-design.md §8.1 标注已实现
- 新增 5 用例,全量 182 passed / 100.00%(987 stmts/252 br)
This commit is contained in:
@@ -12,7 +12,11 @@ class FakeLLMClient:
|
||||
self.calls: list[dict] = []
|
||||
|
||||
def chat(self, *, model, messages, temperature, max_tokens):
|
||||
self.calls.append({"model": model, "messages": [m.content for m in messages]})
|
||||
# 与真实 HttpLLMClient 的 payload 结构一致:{role, content}(T4 防护断言 role)
|
||||
self.calls.append({
|
||||
"model": model,
|
||||
"messages": [{"role": m.role, "content": m.content} for m in messages],
|
||||
})
|
||||
status, content = self.script.pop(0)
|
||||
if status == "raise_timeout":
|
||||
from genesis.inference.exceptions import LLMTimeoutError
|
||||
|
||||
Reference in New Issue
Block a user