add new test and fix previous

This commit is contained in:
Mery-Sanz 2025-04-10 08:54:21 +02:00
parent 777ddaedd9
commit 9532fe42f5
9 changed files with 47 additions and 14 deletions

2
.gitignore vendored
View File

@ -146,4 +146,4 @@ cython_debug/
# CAI files
.cai/
.vscode/
cai_env/

View File

@ -0,0 +1,33 @@
import pytest
from tests.fake_model import FakeModel
from tests.test_responses import (
get_text_message,
get_function_tool_call,
get_function_tool,
)
from cai.sdk.agents import Runner
from cai.agents.one_tool import transfer_to_one_tool_agent
@pytest.mark.asyncio
async def test_ctf_agent_executes_linux_command():
model = FakeModel()
agent = transfer_to_one_tool_agent()
agent.model = model
model.add_multiple_turn_outputs(
[
[
get_text_message("executing comando..."),
get_function_tool_call("generic_linux_command", '{"command": "ls"}')
],
[
get_text_message("result of the command: flag{12345}")
]
]
)
result = await Runner.run(agent, input="List files")
assert result.final_output == "result of the command: flag{12345}"
assert len(result.raw_responses) == 2
assert any("generic_linux_command" in str(item) for item in result.to_input_list())

View File

@ -7,9 +7,9 @@ from inline_snapshot import snapshot
from cai.sdk.agents import Agent, RunConfig, Runner, trace
from .fake_model import FakeModel
from .test_responses import get_text_message
from .testing_processor import assert_no_traces, fetch_normalized_spans
from tests.fake_model import FakeModel
from tests.test_responses import get_text_message
from tests.testing_processor import assert_no_traces, fetch_normalized_spans
@pytest.mark.asyncio

View File

@ -3,8 +3,8 @@ import pytest
from cai.sdk.agents import Agent, ModelSettings, Runner
from cai.sdk.agents._run_impl import AgentToolUseTracker, RunImpl
from .fake_model import FakeModel
from .test_responses import get_function_tool, get_function_tool_call, get_text_message
from tests.fake_model import FakeModel
from tests.test_responses import get_function_tool, get_function_tool_call, get_text_message
class TestToolChoiceReset:

View File

@ -18,7 +18,7 @@ from cai.sdk.agents import (
)
from cai.sdk.agents._run_impl import RunImpl
from .test_responses import get_function_tool
from tests.test_responses import get_function_tool
def _make_function_tool_result(

View File

@ -18,7 +18,7 @@ from cai.sdk.agents.tracing import (
)
from cai.sdk.agents.tracing.spans import SpanError
from .testing_processor import (
from tests.testing_processor import (
SPAN_PROCESSOR_TESTING,
assert_no_traces,
fetch_events,

View File

@ -19,15 +19,15 @@ from cai.sdk.agents import (
TResponseInputItem,
)
from .fake_model import FakeModel
from .test_responses import (
from tests.fake_model import FakeModel
from tests.test_responses import (
get_final_output_message,
get_function_tool,
get_function_tool_call,
get_handoff_tool_call,
get_text_message,
)
from .testing_processor import fetch_normalized_spans
from tests.testing_processor import fetch_normalized_spans
@pytest.mark.asyncio

View File

@ -22,15 +22,15 @@ from cai.sdk.agents import (
TResponseInputItem,
)
from .fake_model import FakeModel
from .test_responses import (
from tests.fake_model import FakeModel
from tests.test_responses import (
get_final_output_message,
get_function_tool,
get_function_tool_call,
get_handoff_tool_call,
get_text_message,
)
from .testing_processor import fetch_normalized_spans
from tests.testing_processor import fetch_normalized_spans
@pytest.mark.asyncio