refactor(auto-memory): remove image switch type validation

This commit is contained in:
wang-qisen 2026-09-20 12:04:26 +08:00
parent c8be319c20
commit 15fdf0ca38
4 changed files with 6 additions and 13 deletions

View file

@ -105,8 +105,8 @@ Then call the running service from another terminal, using the same workspace:
reme auto_memory session_id=session-a include_images=true messages='[...]'
```
Model and formatter limits still apply. When image input is enabled and images are present, Auto Memory checks the option,
wrapper backend, URL schemes and image count before saving the conversation. Later formatter or provider errors are returned
Model and formatter limits still apply. When image input is enabled and images are present, Auto Memory checks the wrapper
backend, URL schemes and image count before saving the conversation. Later formatter or provider errors are returned
without retrying as text-only. As with text-only calls, those errors do not roll back an already saved conversation.
Source JSONL saving follows the filtering rules above, including the omission of Base64 blocks. To process those images

View file

@ -96,8 +96,7 @@ reme start components.agent_wrapper.default.context_config.max_image_num=20
reme auto_memory session_id=session-a include_images=true messages='[...]'
```
模型与 formatter 自身的限制仍然适用。开启图像且消息中包含图像时,才会在保存对话前检查图像选项、wrapper backend、
URL scheme 和图像数量。
模型与 formatter 自身的限制仍然适用。开启图像且消息中包含图像时,才会在保存对话前检查 wrapper backend、URL scheme 和图像数量。
之后的 formatter 或 provider 错误直接返回,不转为纯文本重试;与纯文本调用相同,已保存的对话不会因此回滚。
源 JSONL 仍按上文规则保存,包括过滤 Base64 block。因此,再次处理这些图像需要提交原始消息,而不是读取已保存的 JSONL。

View file

@ -294,8 +294,6 @@ class AutoMemoryStep(BaseStep):
]
if not images:
return messages, {}, None
if not isinstance(include_images, bool):
raise ValueError("include_images must be a boolean")
wrapper = self.agent_wrapper
if wrapper is None or wrapper.backend != "agentscope":
raise NotImplementedError("Auto Memory image inputs require the AgentScope wrapper")

View file

@ -206,7 +206,7 @@ async def test_sources_interleave_unchanged_through_native_formatters(setup, mon
@pytest.mark.asyncio
@pytest.mark.parametrize("existing", [False, True])
@pytest.mark.parametrize("failure", ["bool", "zero", "null", "backend", "file", "ftp", "default-limit"])
@pytest.mark.parametrize("failure", ["backend", "file", "ftp", "default-limit"])
async def test_static_errors_precede_any_source_session_write(setup, existing, failure):
step, wrapper, path = setup
old = _message("old", images=False, timestamp=f"{_DAY}T09:00:00")
@ -215,10 +215,8 @@ async def test_static_errors_precede_any_source_session_write(setup, existing, f
path.parent.mkdir(parents=True)
path.write_bytes(before)
message, options = _message(), {"include_images": True}
error, match = ValueError, "include_images"
if failure in ("bool", "zero", "null"):
options["include_images"] = {"bool": "true", "zero": 0, "null": None}[failure]
elif failure == "backend":
error, match = ValueError, "max_image_num"
if failure == "backend":
step.kwargs["agent_wrapper"] = CcAgentWrapper(backend="claude_code")
error, match = NotImplementedError, "AgentScope"
elif failure in ("file", "ftp"):
@ -226,7 +224,6 @@ async def test_static_errors_precede_any_source_session_write(setup, existing, f
match = "Base64|base64|HTTP|http"
else:
message.content = [_image() for _ in range(6)]
match = "max_image_num"
with pytest.raises(error, match=match):
await _run(step, [message], **options)
@ -354,7 +351,6 @@ async def test_provider_error_is_not_retried_and_keeps_main_saved_source(setup,
("claude_code", True, {}, True, "AgentScope"),
("claude_code", False, {}, True, str),
("claude_code", True, {}, False, str),
("agentscope", False, {"include_images": "true"}, True, "boolean"),
("claude_code", False, {"include_images": "true"}, False, str),
],
)