Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(codex): keep image prompt session scoped
cyh9be91636a57a
diff --git a/modules/agents/codex/agent.py b/modules/agents/codex/agent.pyindex 9b40c8076..2f30de4d7 100644--- a/modules/agents/codex/agent.py+++ b/modules/agents/codex/agent.py@@ -21,18 +21,6 @@ _CODEX_GENERATED_IMAGE_PROMPT = ("If you generate an image with Codex, include it in the final reply with Markdown image syntax: ""``")-_IMAGE_REQUEST_MARKERS = (- "generate an image",- "generate a picture",- "create an image",- "create a picture",- "draw an image",- "draw a picture",- "make an image",- "make a picture",-)-_IMAGE_REQUEST_VERBS = ("生成", "画", "绘制", "绘画", "创作", "generate", "create", "draw", "make")-_IMAGE_REQUEST_NOUNS = ("图片", "图像", "图", "插画", "海报", "照片", "image", "picture", "illustration", "poster", "photo")class CodexAgent(BaseAgent):@@ -455,6 +443,7 @@ class CodexAgent(BaseAgent):fallback_platform=platform,))+ instruction_parts.append(_CODEX_GENERATED_IMAGE_PROMPT)if instruction_parts:params["developerInstructions"] = "\n\n".join(part for part in instruction_parts if part)@@ -650,26 +639,11 @@ class CodexAgent(BaseAgent):if len(file_lines) > 2:message = f"{message}\n" + "\n".join(file_lines)- if message and self._should_add_generated_image_prompt(message):- message = f"{message}\n\n{_CODEX_GENERATED_IMAGE_PROMPT}"-if message:items.insert(0, {"type": "text", "text": message})return items- def _should_add_generated_image_prompt(self, message: str) -> bool:- controller = getattr(self, "controller", None)- config = getattr(controller, "config", None)- if not getattr(config, "reply_enhancements", True):- return False- normalized = " ".join((message or "").lower().split())- if any(marker in normalized for marker in _IMAGE_REQUEST_MARKERS):- return True- return any(verb in normalized for verb in _IMAGE_REQUEST_VERBS) and any(- noun in normalized for noun in _IMAGE_REQUEST_NOUNS- )-# ------------------------------------------------------------------# Callback handlers (wired to transport)# ------------------------------------------------------------------diff --git a/tests/test_codex_agent.py b/tests/test_codex_agent.pyindex a0b8f3af3..13e08067c 100644--- a/tests/test_codex_agent.py+++ b/tests/test_codex_agent.py@@ -675,24 +675,35 @@ class CodexAgentPayloadTests(unittest.IsolatedAsyncioTestCase):},)- def test_build_input_adds_codex_generated_image_prompt_only_for_image_requests(self):+ async def test_start_thread_adds_codex_generated_image_prompt_only_to_codex_developer_instructions(self):agent = object.__new__(CodexAgent)- agent.controller = SimpleNamespace(config=SimpleNamespace(reply_enhancements=True))- request = SimpleNamespace(message="生成一张小图片:白色狐狸站在绿色星球上", files=None)-- items = agent._build_input(request)-- self.assertIn("If you generate an image with Codex", items[0]["text"])- self.assertIn("", items[0]["text"])-- def test_build_input_does_not_add_codex_generated_image_prompt_for_normal_requests(self):- agent = object.__new__(CodexAgent)- agent.controller = SimpleNamespace(config=SimpleNamespace(reply_enhancements=True))- request = SimpleNamespace(message="修复这个 Python 测试失败", files=None)+ agent.controller = SimpleNamespace(config=SimpleNamespace(platform="slack", reply_enhancements=True))+ agent.settings_manager = SimpleNamespace(get_channel_settings=lambda session_key: None)+ agent.codex_config = SimpleNamespace(default_model=None)+ agent._session_mgr = SimpleNamespace(set_thread_id=Mock())+ agent.sessions = SimpleNamespace(set_agent_session_mapping=Mock())+ request = SimpleNamespace(+ working_path="/tmp/work",+ context=SimpleNamespace(+ platform="slack",+ platform_specific={},+ user_id="U1",+ channel_id="C1",+ thread_id=None,+ ),+ base_session_id="session-1",+ session_key="channel-1",+ subagent_name=None,+ subagent_model=None,+ subagent_reasoning_effort=None,+ )+ transport = SimpleNamespace(send_request=AsyncMock(return_value={"thread": {"id": "thread-1"}}))- items = agent._build_input(request)+ await agent._start_thread(transport, request)- self.assertNotIn("If you generate an image with Codex", items[0]["text"])+ params = transport.send_request.await_args.args[1]+ self.assertIn("If you generate an image with Codex", params["developerInstructions"])+ self.assertIn("", params["developerInstructions"])async def test_start_turn_uses_sandbox_policy_object(self):agent = object.__new__(CodexAgent)