fix: enable Codex sandbox in Docker
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import asyncio
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
from agentci.adapters.codex import CodexClient, _session_id
|
||||
from agentci.domain.models import AgentResult
|
||||
|
||||
|
||||
def test_enables_codegraph_in_shared_codex_config() -> None:
|
||||
@@ -65,3 +67,44 @@ def test_configures_research_agent_and_optional_context7_key(tmp_path) -> None:
|
||||
assert 'url = "https://mcp.grep.app"' in agent
|
||||
assert "ctx7-secret" not in agent
|
||||
assert client._environment()["CONTEXT7_API_KEY"] == "ctx7-secret"
|
||||
|
||||
|
||||
async def test_invokes_codex_from_workflow_workspace(tmp_path, monkeypatch) -> None:
|
||||
workspace = tmp_path / "workspace"
|
||||
workspace.mkdir()
|
||||
captured: dict[str, object] = {}
|
||||
|
||||
class Process:
|
||||
returncode = 0
|
||||
|
||||
async def communicate(self, prompt: bytes) -> tuple[bytes, bytes]:
|
||||
assert prompt == b"prompt"
|
||||
return b'{"type":"thread.started","thread_id":"thread"}', b""
|
||||
|
||||
async def create_subprocess_exec(*args, **kwargs):
|
||||
captured["cwd"] = kwargs["cwd"]
|
||||
output = Path(args[args.index("--output-last-message") + 1])
|
||||
output.write_text( # noqa: ASYNC240 - tiny test-owned result file
|
||||
'{"summary_markdown":"summary","tests":[]}'
|
||||
)
|
||||
return Process()
|
||||
|
||||
monkeypatch.setattr(asyncio, "create_subprocess_exec", create_subprocess_exec)
|
||||
client = CodexClient(
|
||||
codex_home=tmp_path / "codex",
|
||||
schemas_dir=tmp_path / "schemas",
|
||||
timeout_seconds=60,
|
||||
research_model="gpt-5.6-luna",
|
||||
research_reasoning="high",
|
||||
context7_api_key=None,
|
||||
)
|
||||
|
||||
_, result = await client._invoke(
|
||||
["codex", "exec", "-"],
|
||||
"prompt",
|
||||
AgentResult,
|
||||
workspace=workspace,
|
||||
)
|
||||
|
||||
assert captured["cwd"] == workspace
|
||||
assert result.summary_markdown == "summary"
|
||||
|
||||
Reference in New Issue
Block a user