mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-19 08:03:19 +08:00
完善 agent/workspace 运行链路与工具结果治理测试覆盖,确保路由、标题生成与上下文截断行为稳定可回归。
同时将 data/wiki 用户数据纳入忽略规则,避免运行态数据被误纳入版本管理。 Made-with: Cursor
This commit is contained in:
parent
45e412b4ab
commit
20362527e2
17 changed files with 974 additions and 41 deletions
|
|
@ -41,3 +41,40 @@ def test_oclaw_tool_result_context_guard_truncates_large_tool_message(tmp_path:
|
|||
assert len(guarded) <= _OCLAW_TOOL_RESULT_HARD_CAP_CHARS + 2000
|
||||
assert "_tool_result_guarded" in guarded
|
||||
|
||||
|
||||
def test_oclaw_tool_result_context_guard_skips_active_turn_tool_messages(tmp_path: Path) -> None:
|
||||
store = SqliteStore(str(tmp_path / "ops.sqlite"))
|
||||
sess = store.create_session("t")
|
||||
turn_uuid = "turn-active-1"
|
||||
store.add_message(
|
||||
session_id=sess.id,
|
||||
role="assistant",
|
||||
content="",
|
||||
tool_calls=[{"id": "c1", "name": "echo", "arguments": {"x": 1}}],
|
||||
turn_uuid=turn_uuid,
|
||||
)
|
||||
huge = "X" * (_OCLAW_TOOL_RESULT_HARD_CAP_CHARS + 5000)
|
||||
store.add_message(
|
||||
session_id=sess.id,
|
||||
role="tool",
|
||||
content='{"ok": true, "blob": "' + huge + '"}',
|
||||
tool_calls={"tool_call_id": "c1", "name": "echo", "assistant_message_id": 1},
|
||||
turn_uuid=turn_uuid,
|
||||
)
|
||||
msgs = _build_model_context(
|
||||
store=store,
|
||||
session_id=sess.id,
|
||||
max_messages=50,
|
||||
system_prompt="sys",
|
||||
model=RuleBasedChatModel(),
|
||||
lang="zh",
|
||||
memory_context=None,
|
||||
trace_id="t1",
|
||||
parent_span_id=None,
|
||||
active_turn_uuid=turn_uuid,
|
||||
)
|
||||
tool_msgs = [m for m in msgs if m.get("role") == "tool"]
|
||||
assert tool_msgs, msgs
|
||||
raw = str(tool_msgs[-1].get("content") or "")
|
||||
assert "_tool_result_guarded" not in raw
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue